Update app.py
Browse files
app.py
CHANGED
|
@@ -6,11 +6,16 @@ import requests
|
|
| 6 |
from io import BytesIO
|
| 7 |
|
| 8 |
# Load model and processor from Hugging Face
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
# Example image URL (replace this with a suitable example)
|
| 16 |
example_image_url = "https://huggingface.co/datasets/nateraw/image-folder/resolve/main/example_1.png"
|
|
@@ -27,6 +32,9 @@ def load_example_image():
|
|
| 27 |
|
| 28 |
# Define function to generate 3D output from 2D image
|
| 29 |
def image_to_3d(image):
|
|
|
|
|
|
|
|
|
|
| 30 |
try:
|
| 31 |
# Preprocess the input image
|
| 32 |
inputs = processor(images=image, return_tensors="pt")
|
|
|
|
| 6 |
from io import BytesIO
|
| 7 |
|
| 8 |
# Load model and processor from Hugging Face
|
| 9 |
+
def load_model_and_processor():
|
| 10 |
+
try:
|
| 11 |
+
model = AutoModel.from_pretrained("zxhezexin/openlrm-mix-large-1.1")
|
| 12 |
+
processor = AutoProcessor.from_pretrained("zxhezexin/openlrm-mix-large-1.1")
|
| 13 |
+
return model, processor
|
| 14 |
+
except Exception as e:
|
| 15 |
+
print(f"Error loading model or processor: {e}")
|
| 16 |
+
return None, None
|
| 17 |
+
|
| 18 |
+
model, processor = load_model_and_processor()
|
| 19 |
|
| 20 |
# Example image URL (replace this with a suitable example)
|
| 21 |
example_image_url = "https://huggingface.co/datasets/nateraw/image-folder/resolve/main/example_1.png"
|
|
|
|
| 32 |
|
| 33 |
# Define function to generate 3D output from 2D image
|
| 34 |
def image_to_3d(image):
|
| 35 |
+
if processor is None or model is None:
|
| 36 |
+
return "Model or processor not loaded."
|
| 37 |
+
|
| 38 |
try:
|
| 39 |
# Preprocess the input image
|
| 40 |
inputs = processor(images=image, return_tensors="pt")
|