Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -28,7 +28,7 @@ def build_transform(input_size):
|
|
28 |
def preprocess_image(image, input_size=448):
|
29 |
"""Preprocess the image to the required format."""
|
30 |
transform = build_transform(input_size)
|
31 |
-
tensor_image = transform(image).unsqueeze(0).to(torch.float32)
|
32 |
return tensor_image
|
33 |
|
34 |
# Load the model and tokenizer
|
@@ -36,7 +36,6 @@ logging.info("Loading model from Hugging Face Hub...")
|
|
36 |
model_path = "OpenGVLab/InternVL2_5-1B"
|
37 |
model = AutoModel.from_pretrained(
|
38 |
model_path,
|
39 |
-
torch_dtype=torch.float32, # Use float32 for CPU compatibility
|
40 |
trust_remote_code=True,
|
41 |
).to(device).eval()
|
42 |
|
@@ -79,4 +78,4 @@ interface = gr.Interface(
|
|
79 |
)
|
80 |
|
81 |
if __name__ == "__main__":
|
82 |
-
interface.launch(server_name="0.0.0.0", server_port=7860
|
|
|
28 |
def preprocess_image(image, input_size=448):
|
29 |
"""Preprocess the image to the required format."""
|
30 |
transform = build_transform(input_size)
|
31 |
+
tensor_image = transform(image).unsqueeze(0).to(torch.float32) # Use float32 for CPU
|
32 |
return tensor_image
|
33 |
|
34 |
# Load the model and tokenizer
|
|
|
36 |
model_path = "OpenGVLab/InternVL2_5-1B"
|
37 |
model = AutoModel.from_pretrained(
|
38 |
model_path,
|
|
|
39 |
trust_remote_code=True,
|
40 |
).to(device).eval()
|
41 |
|
|
|
78 |
)
|
79 |
|
80 |
if __name__ == "__main__":
|
81 |
+
interface.launch(server_name="0.0.0.0", server_port=7860)
|