Spaces:
Running
on
Zero
Running
on
Zero
elliesleightholm
commited on
Commit
•
0f3bf2c
1
Parent(s):
9467a9f
updating to zero gpu
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
import open_clip
|
3 |
import torch
|
@@ -48,6 +49,7 @@ if api_key is None:
|
|
48 |
login(token=api_key)
|
49 |
|
50 |
# Initialize the model and tokenizer
|
|
|
51 |
def load_model(progress=gr.Progress()):
|
52 |
progress(0, "Initializing model...")
|
53 |
model_name = 'hf-hub:Marqo/marqo-ecommerce-embeddings-B'
|
@@ -71,6 +73,7 @@ def load_model(progress=gr.Progress()):
|
|
71 |
model, preprocess_val, text_features = load_model()
|
72 |
|
73 |
# Prediction function
|
|
|
74 |
def predict(image, url):
|
75 |
if url:
|
76 |
response = requests.get(url)
|
@@ -94,6 +97,7 @@ def predict(image, url):
|
|
94 |
return image, top_10_confidences
|
95 |
|
96 |
# Clear function
|
|
|
97 |
def clear_fields():
|
98 |
return None, ""
|
99 |
|
|
|
1 |
+
import spaces
|
2 |
import gradio as gr
|
3 |
import open_clip
|
4 |
import torch
|
|
|
49 |
login(token=api_key)
|
50 |
|
51 |
# Initialize the model and tokenizer
|
52 |
+
@spaces.GPU
|
53 |
def load_model(progress=gr.Progress()):
|
54 |
progress(0, "Initializing model...")
|
55 |
model_name = 'hf-hub:Marqo/marqo-ecommerce-embeddings-B'
|
|
|
73 |
model, preprocess_val, text_features = load_model()
|
74 |
|
75 |
# Prediction function
|
76 |
+
@spaces.GPU
|
77 |
def predict(image, url):
|
78 |
if url:
|
79 |
response = requests.get(url)
|
|
|
97 |
return image, top_10_confidences
|
98 |
|
99 |
# Clear function
|
100 |
+
@spaces.GPU
|
101 |
def clear_fields():
|
102 |
return None, ""
|
103 |
|