Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -118,22 +118,22 @@ MODEL_ID_3B = "nanonets/Nanonets-OCR2-3B"
|
|
| 118 |
processor_3b = AutoProcessor.from_pretrained(MODEL_ID_3B, trust_remote_code=True)
|
| 119 |
model_3b = AutoModelForImageTextToText.from_pretrained(
|
| 120 |
MODEL_ID_3B,
|
| 121 |
-
|
| 122 |
-
device_map="auto",
|
| 123 |
trust_remote_code=True,
|
| 124 |
attn_implementation="flash_attention_2"
|
| 125 |
-
).eval()
|
| 126 |
|
| 127 |
# Load Nanonets-OCR2-1.5B-exp
|
| 128 |
MODEL_ID_1_5B = "nanonets/Nanonets-OCR2-1.5B-exp"
|
| 129 |
processor_1_5b = AutoProcessor.from_pretrained(MODEL_ID_1_5B, trust_remote_code=True)
|
| 130 |
model_1_5b = AutoModelForImageTextToText.from_pretrained(
|
| 131 |
MODEL_ID_1_5B,
|
| 132 |
-
|
| 133 |
-
device_map="auto",
|
| 134 |
trust_remote_code=True,
|
| 135 |
attn_implementation="flash_attention_2"
|
| 136 |
-
).eval()
|
| 137 |
|
| 138 |
@spaces.GPU
|
| 139 |
def generate_image(model_name: str, text: str, image: Image.Image,
|
|
|
|
| 118 |
processor_3b = AutoProcessor.from_pretrained(MODEL_ID_3B, trust_remote_code=True)
|
| 119 |
model_3b = AutoModelForImageTextToText.from_pretrained(
|
| 120 |
MODEL_ID_3B,
|
| 121 |
+
dtype=torch.float16,
|
| 122 |
+
#device_map="auto",
|
| 123 |
trust_remote_code=True,
|
| 124 |
attn_implementation="flash_attention_2"
|
| 125 |
+
).to(device).eval()
|
| 126 |
|
| 127 |
# Load Nanonets-OCR2-1.5B-exp
|
| 128 |
MODEL_ID_1_5B = "nanonets/Nanonets-OCR2-1.5B-exp"
|
| 129 |
processor_1_5b = AutoProcessor.from_pretrained(MODEL_ID_1_5B, trust_remote_code=True)
|
| 130 |
model_1_5b = AutoModelForImageTextToText.from_pretrained(
|
| 131 |
MODEL_ID_1_5B,
|
| 132 |
+
dtype=torch.float16,
|
| 133 |
+
#device_map="auto",
|
| 134 |
trust_remote_code=True,
|
| 135 |
attn_implementation="flash_attention_2"
|
| 136 |
+
).to(device).eval()
|
| 137 |
|
| 138 |
@spaces.GPU
|
| 139 |
def generate_image(model_name: str, text: str, image: Image.Image,
|