Spaces:
Runtime error
Runtime error
File size: 1,208 Bytes
d6d3a5b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
import numpy as np
import gradio as gr
import os
import tempfile
import shutil
# from gradio_inter.predict_from_file import predict_from_file
from gradio_inter.create_bash_file import create_bash_file
def create_temp_file(path: str) -> str:
temp_dir = tempfile.gettempdir()
temp_folder = os.path.join(temp_dir, "denoising")
os.makedirs(temp_folder, exist_ok=True)
# Clean up directory
# for i in os.listdir(temp_folder):
# print("Removing", i)
# os.remove(os.path.join(temp_folder, i))
temp_path = os.path.join(temp_folder, path.split("/")[-1])
shutil.copy2(path, temp_path)
return temp_path
# from gradio_inter.predict import predict_from_data
# from gradio_inter.predi
def transpose(matrix):
return matrix.T
def predict(file_path: str):
temp_file_path = create_temp_file(file_path)
# predict_from_file
temp_bash_file = create_bash_file(temp_file_path)
os.system(f"bash {temp_bash_file}")
demo = gr.Interface(
predict,
# gr.Dataframe(type="numpy", datatype="number", row_count=5, col_count=3),
gr.File(type="filepath"),
"dict",
cache_examples=False
)
if __name__ == "__main__":
demo.launch() |