Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
-
import time
|
4 |
import spaces
|
5 |
-
from typing import Iterable
|
6 |
-
from gradio.themes.base import Base
|
7 |
-
from gradio.themes.utils import colors, fonts, sizes
|
8 |
from transformers import AutoModel, AutoProcessor
|
9 |
|
10 |
from gender_classification import gender_classification
|
@@ -26,45 +22,6 @@ from multisource_121 import multisource_classification
|
|
26 |
from painting_126 import painting_classification
|
27 |
from sketch_126 import sketch_classification # New import
|
28 |
|
29 |
-
#Gradio-Theme
|
30 |
-
class Seafoam(Base):
|
31 |
-
def __init__(
|
32 |
-
self,
|
33 |
-
*,
|
34 |
-
primary_hue: colors.Color | str = colors.emerald,
|
35 |
-
secondary_hue: colors.Color | str = colors.blue,
|
36 |
-
neutral_hue: colors.Color | str = colors.gray,
|
37 |
-
spacing_size: sizes.Size | str = sizes.spacing_md,
|
38 |
-
radius_size: sizes.Size | str = sizes.radius_md,
|
39 |
-
text_size: sizes.Size | str = sizes.text_lg,
|
40 |
-
font: fonts.Font
|
41 |
-
| str
|
42 |
-
| Iterable[fonts.Font | str] = (
|
43 |
-
fonts.GoogleFont("Quicksand"),
|
44 |
-
"ui-sans-serif",
|
45 |
-
"sans-serif",
|
46 |
-
),
|
47 |
-
font_mono: fonts.Font
|
48 |
-
| str
|
49 |
-
| Iterable[fonts.Font | str] = (
|
50 |
-
fonts.GoogleFont("IBM Plex Mono"),
|
51 |
-
"ui-monospace",
|
52 |
-
"monospace",
|
53 |
-
),
|
54 |
-
):
|
55 |
-
super().__init__(
|
56 |
-
primary_hue=primary_hue,
|
57 |
-
secondary_hue=secondary_hue,
|
58 |
-
neutral_hue=neutral_hue,
|
59 |
-
spacing_size=spacing_size,
|
60 |
-
radius_size=radius_size,
|
61 |
-
text_size=text_size,
|
62 |
-
font=font,
|
63 |
-
font_mono=font_mono,
|
64 |
-
)
|
65 |
-
|
66 |
-
seafoam = Seafoam()
|
67 |
-
|
68 |
# Main classification function for multi-model classification.
|
69 |
def classify(image, model_name):
|
70 |
if model_name == "gender":
|
@@ -155,7 +112,7 @@ def infer(image, candidate_labels):
|
|
155 |
return postprocess_siglip(sg1_probs, sg2_probs, labels=candidate_labels)
|
156 |
|
157 |
# Build the Gradio Interface with two tabs.
|
158 |
-
with gr.Blocks(theme=
|
159 |
gr.Markdown("# Multi-Domain & Zero-Shot Image Classification")
|
160 |
|
161 |
with gr.Tabs():
|
|
|
1 |
import gradio as gr
|
2 |
import torch
|
|
|
3 |
import spaces
|
|
|
|
|
|
|
4 |
from transformers import AutoModel, AutoProcessor
|
5 |
|
6 |
from gender_classification import gender_classification
|
|
|
22 |
from painting_126 import painting_classification
|
23 |
from sketch_126 import sketch_classification # New import
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
# Main classification function for multi-model classification.
|
26 |
def classify(image, model_name):
|
27 |
if model_name == "gender":
|
|
|
112 |
return postprocess_siglip(sg1_probs, sg2_probs, labels=candidate_labels)
|
113 |
|
114 |
# Build the Gradio Interface with two tabs.
|
115 |
+
with gr.Blocks(theme="allenai/gradio-theme") as demo:
|
116 |
gr.Markdown("# Multi-Domain & Zero-Shot Image Classification")
|
117 |
|
118 |
with gr.Tabs():
|