Spaces:
Running
on
Zero
Running
on
Zero
Update app_local.py
Browse files- app_local.py +0 -15
app_local.py
CHANGED
|
@@ -84,21 +84,6 @@ Please provide the rewritten instruction in a clean `json` format as:
|
|
| 84 |
'''
|
| 85 |
|
| 86 |
|
| 87 |
-
def add_noise_to_image(pil_image, noise_level=0.02):
|
| 88 |
-
"""Add slight noise to image to create variation in outputs"""
|
| 89 |
-
try:
|
| 90 |
-
img_array = np.array(pil_image).astype(np.float32) / 255.0
|
| 91 |
-
noise = np.random.normal(0, noise_level, img # Clip values to valid range
|
| 92 |
-
noisy_array = np.clip(noisy_array, 0, 1)
|
| 93 |
-
|
| 94 |
-
# Convert back to PIL
|
| 95 |
-
noisy_array = (noisy_array * 255).astype(np.uint8)
|
| 96 |
-
return Image.fromarray(noisy_array)
|
| 97 |
-
except Exception as e:
|
| 98 |
-
print(f"Warning: Could not add noise to image: {e}")
|
| 99 |
-
return pil_image # Return original if noise addition fails
|
| 100 |
-
|
| 101 |
-
|
| 102 |
def extract_json_response(model_output: str) -> str:
|
| 103 |
"""Extract rewritten instruction from potentially messy JSON output"""
|
| 104 |
# Remove code block markers first
|
|
|
|
| 84 |
'''
|
| 85 |
|
| 86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
def extract_json_response(model_output: str) -> str:
|
| 88 |
"""Extract rewritten instruction from potentially messy JSON output"""
|
| 89 |
# Remove code block markers first
|