Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ torch.jit.script = lambda f: f
|
|
8 |
# Initialize the model only once
|
9 |
# if torch.cuda.is_available():
|
10 |
# model_pipe = VQAScore(model="clip-flant5-xl", device="cpu") # our recommended scoring model
|
11 |
-
print("Model initialized!")
|
12 |
|
13 |
@spaces.GPU
|
14 |
def generate(model_name, image, text):
|
@@ -22,13 +22,12 @@ def generate(model_name, image, text):
|
|
22 |
print("Text:", text)
|
23 |
model_pipe = VQAScore(model="clip-flant5-xl") # our recommended scoring model
|
24 |
# print("Model initialized, now moving to cuda")
|
25 |
-
|
26 |
print("Generating!")
|
27 |
# with torch.autocast(device_type='cuda'):
|
28 |
-
with torch.autocast(device_type='cuda', dtype=torch.float):
|
29 |
-
|
30 |
-
|
31 |
-
# return 10
|
32 |
|
33 |
iface = gr.Interface(
|
34 |
fn=generate, # function to call
|
|
|
8 |
# Initialize the model only once
|
9 |
# if torch.cuda.is_available():
|
10 |
# model_pipe = VQAScore(model="clip-flant5-xl", device="cpu") # our recommended scoring model
|
11 |
+
# print("Model initialized!")
|
12 |
|
13 |
@spaces.GPU
|
14 |
def generate(model_name, image, text):
|
|
|
22 |
print("Text:", text)
|
23 |
model_pipe = VQAScore(model="clip-flant5-xl") # our recommended scoring model
|
24 |
# print("Model initialized, now moving to cuda")
|
25 |
+
model_pipe.to("cuda")
|
26 |
print("Generating!")
|
27 |
# with torch.autocast(device_type='cuda'):
|
28 |
+
# with torch.autocast(device_type='cuda', dtype=torch.float):
|
29 |
+
result = model_pipe(images=[image], texts=[text])
|
30 |
+
return result
|
|
|
31 |
|
32 |
iface = gr.Interface(
|
33 |
fn=generate, # function to call
|