Spaces:
Sleeping
Sleeping
Commit
·
5ef548f
1
Parent(s):
5057a68
Install error fix attemp 11
Browse files
main.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from fastapi import FastAPI,
|
2 |
from fastapi.responses import JSONResponse
|
3 |
from pydantic import BaseModel
|
4 |
from PIL import Image
|
@@ -28,12 +28,12 @@ async def load_model():
|
|
28 |
try:
|
29 |
logger.info("Starting model loading...")
|
30 |
|
31 |
-
# Import required modules
|
32 |
-
from transformers import
|
33 |
|
34 |
logger.info("Loading processor...")
|
35 |
-
# Use
|
36 |
-
processor =
|
37 |
model_name,
|
38 |
trust_remote_code=True
|
39 |
)
|
@@ -42,8 +42,8 @@ async def load_model():
|
|
42 |
tokenizer = processor.tokenizer
|
43 |
|
44 |
logger.info("Loading model...")
|
45 |
-
# Use
|
46 |
-
model =
|
47 |
model_name,
|
48 |
torch_dtype=torch.float32,
|
49 |
device_map=None, # CPU only
|
@@ -248,12 +248,4 @@ async def health_check():
|
|
248 |
"device": "cpu",
|
249 |
"torch_dtype": "float32",
|
250 |
"model_loaded": model_loaded
|
251 |
-
}
|
252 |
-
|
253 |
-
@app.post("/click/form")
|
254 |
-
async def predict_click_form(
|
255 |
-
image_base64: str = Form(...),
|
256 |
-
instruction: str = Form(...)
|
257 |
-
):
|
258 |
-
data = Base64Request(image_base64=image_base64, instruction=instruction)
|
259 |
-
return await predict_click_base64(data)
|
|
|
1 |
+
from fastapi import FastAPI, HTTPException
|
2 |
from fastapi.responses import JSONResponse
|
3 |
from pydantic import BaseModel
|
4 |
from PIL import Image
|
|
|
28 |
try:
|
29 |
logger.info("Starting model loading...")
|
30 |
|
31 |
+
# Import required modules - use specific Qwen2VL classes
|
32 |
+
from transformers import Qwen2VLProcessor, Qwen2VLForConditionalGeneration
|
33 |
|
34 |
logger.info("Loading processor...")
|
35 |
+
# Use specific Qwen2VL processor
|
36 |
+
processor = Qwen2VLProcessor.from_pretrained(
|
37 |
model_name,
|
38 |
trust_remote_code=True
|
39 |
)
|
|
|
42 |
tokenizer = processor.tokenizer
|
43 |
|
44 |
logger.info("Loading model...")
|
45 |
+
# Use specific Qwen2VL model class
|
46 |
+
model = Qwen2VLForConditionalGeneration.from_pretrained(
|
47 |
model_name,
|
48 |
torch_dtype=torch.float32,
|
49 |
device_map=None, # CPU only
|
|
|
248 |
"device": "cpu",
|
249 |
"torch_dtype": "float32",
|
250 |
"model_loaded": model_loaded
|
251 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|