|
import gradio as gr |
|
from huggingface_hub import hf_hub_download |
|
import pickle |
|
import gradio as gr |
|
import numpy as np |
|
import subprocess |
|
import shutil |
|
|
|
def process_file(file, model_name): |
|
with open(file.name, 'r') as f: |
|
content = f.read() |
|
saved_test_dataset = "test.txt" |
|
saved_test_label = "saved_test_label.txt" |
|
|
|
|
|
shutil.copyfile(file.name, saved_test_dataset) |
|
|
|
subprocess.run(["python", "src/test_saved_model.py"]) |
|
return f"Model: {model_name}\nContent:\n{content}" |
|
|
|
|
|
models = ["Model A", "Model B", "Model C"] |
|
|
|
|
|
with gr.Blocks() as demo: |
|
gr.Markdown("# File Processor with Model Selection") |
|
gr.Markdown("Upload a .txt file and select a model from the dropdown menu.") |
|
|
|
with gr.Row(): |
|
file_input = gr.File(label="Upload a .txt file", file_types=['.txt']) |
|
model_dropdown = gr.Dropdown(choices=models, label="Select a model") |
|
|
|
output_text = gr.Textbox(label="Output") |
|
|
|
btn = gr.Button("Submit") |
|
btn.click(fn=process_file, inputs=[file_input, model_dropdown], outputs=output_text) |
|
|
|
|
|
demo.launch() |
|
|