abiyyufahri commited on
Commit
5ef548f
·
1 Parent(s): 5057a68

Install error fix attemp 11

Browse files
Files changed (1) hide show
  1. main.py +8 -16
main.py CHANGED
@@ -1,4 +1,4 @@
1
- from fastapi import FastAPI, Form, HTTPException
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 AutoProcessor, AutoModelForCausalLM
33
 
34
  logger.info("Loading processor...")
35
- # Use AutoProcessor for better compatibility
36
- processor = AutoProcessor.from_pretrained(
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 AutoModelForCausalLM for better compatibility
46
- model = AutoModelForCausalLM.from_pretrained(
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
+ }