Spaces:
Runtime error
Runtime error
Download app.py from DavidLee2024/RSNAdemo: direct link, hf CLI and curl.
- Browser
- Download file 972 Bytes
-
https://huggingface.co/spaces/DavidLee2024/RSNAdemo/resolve/main/app.py
- Command line
-
hf download hf://spaces/DavidLee2024/RSNAdemo/app.py
-
curl -L -o app.py https://huggingface.co/spaces/DavidLee2024/RSNAdemo/resolve/main/app.py
972 Bytes
| import os | |
| import gradio as gr | |
| import zipfile | |
| import uuid | |
| import numpy as np | |
| def process_file(zip_file): | |
| temp_folder = "./temp_folder/{}/".format(uuid.uuid1()) | |
| os.makedirs(temp_folder, exist_ok=True) | |
| with zipfile.ZipFile(zip_file, 'r') as zip_ref: | |
| zip_ref.extractall(temp_folder) | |
| dirs = os.listdir(temp_folder) | |
| valid_dirs = [d for d in dirs if '__MACOSX' not in d] | |
| if len(valid_dirs) != 1: | |
| return "only support 1 study id, check your zip file " | |
| study_id = valid_dirs[0] | |
| dirs = os.listdir(temp_folder +'/'+study_id) | |
| message = 'your file: \n' | |
| for d in dirs: | |
| message += f'{d}\n' | |
| os.rmdir(temp_folder) | |
| return message, np.zeros((256, 256, 3), dtype=np.uint8) | |
| demo = gr.Interface(fn=process_file, | |
| inputs=gr.File(), | |
| outputs=[gr.Text(label='text window'), | |
| gr.Image(label='image window')]) | |
| if __name__ == "__main__": | |
| demo.launch() |