Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
import torch
|
|
|
3 |
from transformers import AutoModel, AutoProcessor
|
|
|
4 |
from gender_classification import gender_classification
|
5 |
from emotion_classification import emotion_classification
|
6 |
from dog_breed import dog_breed_classification
|
@@ -72,6 +74,7 @@ siglip2_model = AutoModel.from_pretrained(sg2_ckpt, device_map="cpu").eval()
|
|
72 |
siglip2_processor = AutoProcessor.from_pretrained(sg2_ckpt)
|
73 |
|
74 |
# Utilities for zero-shot classification.
|
|
|
75 |
def postprocess_siglip(sg1_probs, sg2_probs, labels):
|
76 |
sg1_output = {labels[i]: sg1_probs[0][i].item() for i in range(len(labels))}
|
77 |
sg2_output = {labels[i]: sg2_probs[0][i].item() for i in range(len(labels))}
|
|
|
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
|
7 |
from emotion_classification import emotion_classification
|
8 |
from dog_breed import dog_breed_classification
|
|
|
74 |
siglip2_processor = AutoProcessor.from_pretrained(sg2_ckpt)
|
75 |
|
76 |
# Utilities for zero-shot classification.
|
77 |
+
@spaces.GPU
|
78 |
def postprocess_siglip(sg1_probs, sg2_probs, labels):
|
79 |
sg1_output = {labels[i]: sg1_probs[0][i].item() for i in range(len(labels))}
|
80 |
sg2_output = {labels[i]: sg2_probs[0][i].item() for i in range(len(labels))}
|