Spaces:
Running on Zero
Running on Zero
fixed args
Browse files
app.py
CHANGED
|
@@ -5,8 +5,6 @@ import gradio
|
|
| 5 |
from PIL import Image
|
| 6 |
from huggingface_hub import hf_hub_download
|
| 7 |
from models.linear_predictor import Predictor
|
| 8 |
-
from torch.utils.data import Dataset
|
| 9 |
-
from TestSampleDataset import TestDataset
|
| 10 |
import numpy
|
| 11 |
import os
|
| 12 |
|
|
@@ -63,7 +61,7 @@ for i in range(number_of_examples):
|
|
| 63 |
example_rows.append([file_path, truth_label_text])
|
| 64 |
|
| 65 |
@spaces.GPU
|
| 66 |
-
def predict(image):
|
| 67 |
if image is None:
|
| 68 |
return None
|
| 69 |
|
|
@@ -91,12 +89,17 @@ with gradio.Blocks() as demo:
|
|
| 91 |
gradio.Markdown("Click an example below to test the model against the PathMNIST test dataset.")
|
| 92 |
|
| 93 |
# Create a read-only text box to display the column for Truth Labels
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
|
| 96 |
gradio.Examples(
|
| 97 |
examples=example_rows, # Passes both the image file path and the text label
|
| 98 |
-
inputs=[
|
| 99 |
-
outputs=
|
| 100 |
fn=predict,
|
| 101 |
cache_examples=True,
|
| 102 |
)
|
|
|
|
| 5 |
from PIL import Image
|
| 6 |
from huggingface_hub import hf_hub_download
|
| 7 |
from models.linear_predictor import Predictor
|
|
|
|
|
|
|
| 8 |
import numpy
|
| 9 |
import os
|
| 10 |
|
|
|
|
| 61 |
example_rows.append([file_path, truth_label_text])
|
| 62 |
|
| 63 |
@spaces.GPU
|
| 64 |
+
def predict(image,truth_labels=None):
|
| 65 |
if image is None:
|
| 66 |
return None
|
| 67 |
|
|
|
|
| 89 |
gradio.Markdown("Click an example below to test the model against the PathMNIST test dataset.")
|
| 90 |
|
| 91 |
# Create a read-only text box to display the column for Truth Labels
|
| 92 |
+
with gradio.Column():
|
| 93 |
+
input_img_ex = gradio.Image(label="Selected Test Image")
|
| 94 |
+
truth_box = gradio.Textbox(label="Ground Truth Label", interactive=False)
|
| 95 |
+
|
| 96 |
+
with gradio.Column():
|
| 97 |
+
output_lbl_ex = gradio.Label(num_top_classes=3, label="Model Prediction")
|
| 98 |
|
| 99 |
gradio.Examples(
|
| 100 |
examples=example_rows, # Passes both the image file path and the text label
|
| 101 |
+
inputs=[input_img_ex, truth_box], # Maps the data columns to both UI components
|
| 102 |
+
outputs=output_lbl_ex,
|
| 103 |
fn=predict,
|
| 104 |
cache_examples=True,
|
| 105 |
)
|