Spaces:
Sleeping
Sleeping
Nope lmao
Browse files
app.py
CHANGED
|
@@ -9,6 +9,7 @@ from huggingface_hub import hf_hub_download
|
|
| 9 |
MODEL_REPO = "AngelBottomless/camie-tagger-onnxruntime"
|
| 10 |
MODEL_FILE = "camie_tagger_initial.onnx"
|
| 11 |
META_FILE = "metadata.json"
|
|
|
|
| 12 |
DEFAULT_THRESHOLD = 0.35 # Default value if slider is not used
|
| 13 |
|
| 14 |
# Download model and metadata from Hugging Face Hub
|
|
@@ -26,7 +27,7 @@ def escape_tag(tag: str) -> str:
|
|
| 26 |
|
| 27 |
def preprocess_image(pil_image: Image.Image) -> np.ndarray:
|
| 28 |
"""Convert image to RGB, resize, normalize, and rearrange dimensions."""
|
| 29 |
-
img = pil_image.convert("RGB")
|
| 30 |
arr = np.array(img).astype(np.float32) / 255.0
|
| 31 |
arr = np.transpose(arr, (2, 0, 1))
|
| 32 |
return np.expand_dims(arr, 0)
|
|
|
|
| 9 |
MODEL_REPO = "AngelBottomless/camie-tagger-onnxruntime"
|
| 10 |
MODEL_FILE = "camie_tagger_initial.onnx"
|
| 11 |
META_FILE = "metadata.json"
|
| 12 |
+
IMAGE_SIZE = (512, 512)
|
| 13 |
DEFAULT_THRESHOLD = 0.35 # Default value if slider is not used
|
| 14 |
|
| 15 |
# Download model and metadata from Hugging Face Hub
|
|
|
|
| 27 |
|
| 28 |
def preprocess_image(pil_image: Image.Image) -> np.ndarray:
|
| 29 |
"""Convert image to RGB, resize, normalize, and rearrange dimensions."""
|
| 30 |
+
img = pil_image.convert("RGB").resize(IMAGE_SIZE)
|
| 31 |
arr = np.array(img).astype(np.float32) / 255.0
|
| 32 |
arr = np.transpose(arr, (2, 0, 1))
|
| 33 |
return np.expand_dims(arr, 0)
|