Spaces:
Runtime error
Runtime error
Kottu
commited on
Upload 2 files
Browse files- app.py +37 -0
- requirements.txt +4 -0
app.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from PIL import Image # For image handling
|
| 3 |
+
|
| 4 |
+
# Replace with paths or loading functions for your specific models
|
| 5 |
+
def load_model_1():
|
| 6 |
+
# ... load your first model
|
| 7 |
+
return model_1
|
| 8 |
+
|
| 9 |
+
def load_model_2():
|
| 10 |
+
# ... load your second model
|
| 11 |
+
return model_2
|
| 12 |
+
|
| 13 |
+
def load_model_3():
|
| 14 |
+
# ... load your third model
|
| 15 |
+
return model_3
|
| 16 |
+
|
| 17 |
+
def generate_caption(model, image):
|
| 18 |
+
# ... perform inference with your model
|
| 19 |
+
return caption
|
| 20 |
+
|
| 21 |
+
models = [load_model_1(), load_model_2(), load_model_3()]
|
| 22 |
+
|
| 23 |
+
with gr.Blocks() as demo:
|
| 24 |
+
with gr.Row():
|
| 25 |
+
image = gr.Image(label="Upload Chest X-ray")
|
| 26 |
+
with gr.Row():
|
| 27 |
+
gr.Radio(["Model 1", "Model 2", "Model 3"], label="Select Model")
|
| 28 |
+
with gr.Row():
|
| 29 |
+
caption = gr.Textbox(label="Generated Caption")
|
| 30 |
+
|
| 31 |
+
image.change(
|
| 32 |
+
fn=generate_caption,
|
| 33 |
+
inputs=[image, gr.inputs.Radio],
|
| 34 |
+
outputs=caption
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
transformers # Assuming you're using transformers models
|
| 3 |
+
torchvision # For image handling
|
| 4 |
+
pillow
|