Spaces:
Running
on
Zero
Running
on
Zero
Update utils.py
Browse files
utils.py
CHANGED
@@ -91,4 +91,17 @@ def is_google_colab():
|
|
91 |
import google.colab
|
92 |
return True
|
93 |
except:
|
94 |
-
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
import google.colab
|
92 |
return True
|
93 |
except:
|
94 |
+
return False
|
95 |
+
|
96 |
+
def validate_json_parameters(json_str):
|
97 |
+
try:
|
98 |
+
params = json.loads(json_str)
|
99 |
+
required_keys = ['prompt', 'negative_prompt', 'seed', 'width', 'height', 'guidance_scale', 'num_inference_steps', 'sampler']
|
100 |
+
for key in required_keys:
|
101 |
+
if key not in params:
|
102 |
+
raise ValueError(f"Missing required key: {key}")
|
103 |
+
return params
|
104 |
+
except json.JSONDecodeError:
|
105 |
+
raise ValueError("Invalid JSON format")
|
106 |
+
except Exception as e:
|
107 |
+
raise ValueError(f"Error parsing JSON: {str(e)}")
|