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