Spaces:
Running
Running
Uploading Trashify box detection model app.py
Browse files
app.py
CHANGED
|
@@ -13,9 +13,14 @@ from transformers import AutoModelForObjectDetection
|
|
| 13 |
# Note: Can load from Hugging Face or can load from local
|
| 14 |
model_save_path = "mrdbourke/rt_detrv2_finetuned_trashify_box_detector_v1"
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
#
|
| 18 |
image_processor = AutoImageProcessor.from_pretrained(model_save_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
model = AutoModelForObjectDetection.from_pretrained(model_save_path)
|
| 20 |
|
| 21 |
# Set the target device (use CUDA/GPU if it is available)
|
|
|
|
| 13 |
# Note: Can load from Hugging Face or can load from local
|
| 14 |
model_save_path = "mrdbourke/rt_detrv2_finetuned_trashify_box_detector_v1"
|
| 15 |
|
| 16 |
+
# Note: Because this app.py file is running directly on Hugging Face Spaces, the processor/model will be loaded from the Hugging Face Hub
|
| 17 |
+
# Load the processor
|
| 18 |
image_processor = AutoImageProcessor.from_pretrained(model_save_path)
|
| 19 |
+
# Default to resizing images to 640x640, makes things simple as well as
|
| 20 |
+
# helps handle edge case images with strange dimensions
|
| 21 |
+
image_processor.size = {"height": 640,
|
| 22 |
+
"width": 640}
|
| 23 |
+
# Load the model
|
| 24 |
model = AutoModelForObjectDetection.from_pretrained(model_save_path)
|
| 25 |
|
| 26 |
# Set the target device (use CUDA/GPU if it is available)
|