Commit
•
0f4c416
1
Parent(s):
8dbd1d3
Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,18 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
gradio_app = gr.Interface(
|
11 |
-
predict,
|
12 |
-
inputs=gr.Image(label="Select bike, cars, cats, dogs, flowers candidate", sources=['upload', 'webcam'], type="pil"),
|
13 |
-
outputs=[gr.Image(label="Processed Image"), gr.Label(label="Result", num_top_classes=2)],
|
14 |
-
title="bike? Or cars? Or cats? Or dogs? Or flowers?",
|
15 |
-
)
|
16 |
-
|
17 |
-
gradio_app.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import numpy as np
|
3 |
|
4 |
+
# Function to classify images into 7 classes
|
5 |
+
def image_classifier(inp):
|
6 |
+
# Dummy classification logic
|
7 |
+
# Generating random confidence scores for each class
|
8 |
+
confidence_scores = np.random.rand(7)
|
9 |
+
# Normalizing confidence scores to sum up to 1
|
10 |
+
confidence_scores /= np.sum(confidence_scores)
|
11 |
+
# Creating a dictionary with class labels and corresponding confidence scores
|
12 |
+
classes = ['Hor', 'Jadrima', 'Kishuthara', 'Marthra', 'Pangtse', 'Serthra', 'Shinglo']
|
13 |
+
result = {classes[i]: confidence_scores[i] for i in range(7)}
|
14 |
+
return result
|
15 |
|
16 |
+
# Creating Gradio interface
|
17 |
+
demo = gr.Interface(fn=image_classifier, inputs="image", outputs="label")
|
18 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|