gene-hoi-denoising / test_predict_from_file.py
meow
a
d204888
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
from sample.reconstruct_data_taco import reconstruct_from_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
print(f"temp_path: {temp_file_path}")
temp_bash_file = create_bash_file(temp_file_path)
print(f"temp_bash_file: {temp_bash_file}")
# os.system(f"bash {temp_bash_file}")
saved_path = reconstruct_from_file(temp_file_path)
print(saved_path)
# 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__":
file_path = "/home/xueyi/sim/Generalizable-HOI-Denoising/data/taco/source_data/20231104_017.pkl"
predict(file_path=file_path)