Spaces:
Runtime error
Runtime error
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}") | |
res_file_path = "/tmp/denoising/save/predicted_infos_seed_0_tag_20231104_017_jts_spatial_t_100__st_0.npy" | |
return res_file_path | |
demo = gr.Interface( | |
predict, | |
# gr.Dataframe(type="numpy", datatype="number", row_count=5, col_count=3), | |
gr.File(type="filepath"), | |
gr.File(type="filepath"), | |
cache_examples=False | |
) | |
if __name__ == "__main__": | |
demo.launch() |