Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -13,13 +13,13 @@ subprocess.run(
|
|
13 |
shell=True,
|
14 |
)
|
15 |
|
16 |
-
|
17 |
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
|
18 |
|
19 |
Florence_models = AutoModelForCausalLM.from_pretrained(
|
20 |
"microsoft/Florence-2-large",
|
21 |
torch_dtype=torch_dtype,
|
22 |
-
trust_remote_code=True).to(
|
23 |
|
24 |
Florence_processors = AutoProcessor.from_pretrained(
|
25 |
"microsoft/Florence-2-large", trust_remote_code=True)
|
@@ -38,7 +38,7 @@ def feifeiflorence(
|
|
38 |
|
39 |
inputs = Florence_processors(text=task_prompt,
|
40 |
images=image,
|
41 |
-
return_tensors="pt").to(
|
42 |
|
43 |
generated_ids = Florence_models.generate(
|
44 |
input_ids=inputs["input_ids"],
|
|
|
13 |
shell=True,
|
14 |
)
|
15 |
|
16 |
+
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
17 |
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
|
18 |
|
19 |
Florence_models = AutoModelForCausalLM.from_pretrained(
|
20 |
"microsoft/Florence-2-large",
|
21 |
torch_dtype=torch_dtype,
|
22 |
+
trust_remote_code=True).to(device)
|
23 |
|
24 |
Florence_processors = AutoProcessor.from_pretrained(
|
25 |
"microsoft/Florence-2-large", trust_remote_code=True)
|
|
|
38 |
|
39 |
inputs = Florence_processors(text=task_prompt,
|
40 |
images=image,
|
41 |
+
return_tensors="pt").to(device, torch_dtype)
|
42 |
|
43 |
generated_ids = Florence_models.generate(
|
44 |
input_ids=inputs["input_ids"],
|