File size: 1,583 Bytes
d6d3a5b
 
 
 
 
 
 
 
 
 
 
 
 
 
d204888
 
d6d3a5b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d204888
d6d3a5b
 
 
d204888
 
 
 
 
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
53
54
55
56
57
58
59
60
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)