Spaces:
Running
on
Zero
Running
on
Zero
derektan
commited on
Commit
·
fed0b3b
1
Parent(s):
44fb3df
Alowed for text inputs with special chars
Browse files
app.py
CHANGED
|
@@ -216,9 +216,9 @@ def inference(input_str, input_image):
|
|
| 216 |
|
| 217 |
print("input_str: ", input_str, "input_image: ", input_image)
|
| 218 |
|
| 219 |
-
##
|
| 220 |
-
if
|
| 221 |
-
output_str = f"[Error] Invalid input: {input_str}"
|
| 222 |
# Create a red placeholder image to indicate an error
|
| 223 |
output_image = np.zeros((128, 128, 3), dtype=np.uint8)
|
| 224 |
output_image[:] = (0, 0, 0) # Red color in RGB
|
|
|
|
| 216 |
|
| 217 |
print("input_str: ", input_str, "input_image: ", input_image)
|
| 218 |
|
| 219 |
+
## basic validity check: non-empty and reasonable length only
|
| 220 |
+
if len(input_str.strip()) == 0 or len(input_str) > 1024:
|
| 221 |
+
output_str = f"[Error] Invalid input length: {len(input_str)}"
|
| 222 |
# Create a red placeholder image to indicate an error
|
| 223 |
output_image = np.zeros((128, 128, 3), dtype=np.uint8)
|
| 224 |
output_image[:] = (0, 0, 0) # Red color in RGB
|