Update app.py
Browse files
app.py
CHANGED
@@ -116,6 +116,26 @@ index_html = """
|
|
116 |
button.disabled = false; // ボタンを再有効化
|
117 |
}
|
118 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
</script>
|
120 |
</head>
|
121 |
<body>
|
@@ -128,12 +148,12 @@ index_html = """
|
|
128 |
<input type="text" id="negative_prompt" name="negative_prompt" value="(deformed, distorted, disfigured), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, (mutated hands and fingers), disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation, misspellings, typos"><br><br>
|
129 |
|
130 |
<label for="width">Width:</label>
|
131 |
-
<input type="
|
132 |
-
<
|
133 |
|
134 |
<label for="height">Height:</label>
|
135 |
-
<input type="
|
136 |
-
<
|
137 |
|
138 |
<label for="steps">Sampling Steps:</label>
|
139 |
<input type="number" id="steps" name="steps" value="35"><br><br>
|
@@ -177,24 +197,22 @@ def generate_image():
|
|
177 |
steps = int(request.args.get("steps", 35))
|
178 |
cfg_scale = float(request.args.get("cfgs", 7))
|
179 |
sampler = request.args.get("sampler", "DPM++ 2M Karras")
|
180 |
-
seed = int(request.args.get("seed", -1))
|
181 |
strength = float(request.args.get("strength", 0.7))
|
|
|
182 |
width = int(request.args.get("width", 1024))
|
183 |
height = int(request.args.get("height", 1024))
|
184 |
|
185 |
# Call the query function to generate the image
|
186 |
image, error = query(prompt, negative_prompt, steps, cfg_scale, sampler, seed, strength, width, height)
|
187 |
-
|
188 |
if error:
|
189 |
-
return jsonify({"error": error}),
|
190 |
-
|
191 |
-
# Save the image to a buffer
|
192 |
-
img_io = io.BytesIO()
|
193 |
-
image.save(img_io, 'PNG')
|
194 |
-
img_io.seek(0)
|
195 |
|
196 |
-
#
|
197 |
-
|
|
|
|
|
|
|
198 |
|
199 |
-
if __name__ ==
|
200 |
app.run(host='0.0.0.0', port=7860)
|
|
|
116 |
button.disabled = false; // ボタンを再有効化
|
117 |
}
|
118 |
}
|
119 |
+
|
120 |
+
function syncWidth(value) {
|
121 |
+
document.getElementById("width").value = value;
|
122 |
+
}
|
123 |
+
|
124 |
+
function syncHeight(value) {
|
125 |
+
document.getElementById("height").value = value;
|
126 |
+
}
|
127 |
+
|
128 |
+
function updateWidthInput() {
|
129 |
+
const widthSlider = document.getElementById("width-slider");
|
130 |
+
const widthInput = document.getElementById("width");
|
131 |
+
widthInput.value = widthSlider.value;
|
132 |
+
}
|
133 |
+
|
134 |
+
function updateHeightInput() {
|
135 |
+
const heightSlider = document.getElementById("height-slider");
|
136 |
+
const heightInput = document.getElementById("height");
|
137 |
+
heightInput.value = heightSlider.value;
|
138 |
+
}
|
139 |
</script>
|
140 |
</head>
|
141 |
<body>
|
|
|
148 |
<input type="text" id="negative_prompt" name="negative_prompt" value="(deformed, distorted, disfigured), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, (mutated hands and fingers), disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation, misspellings, typos"><br><br>
|
149 |
|
150 |
<label for="width">Width:</label>
|
151 |
+
<input type="number" id="width" name="width" value="1024" min="64" max="2048" step="8" oninput="syncWidth(this.value)">
|
152 |
+
<input type="range" id="width-slider" name="width-slider" min="64" max="2048" value="1024" step="8" oninput="updateWidthInput()"><br><br>
|
153 |
|
154 |
<label for="height">Height:</label>
|
155 |
+
<input type="number" id="height" name="height" value="1024" min="64" max="2048" step="8" oninput="syncHeight(this.value)">
|
156 |
+
<input type="range" id="height-slider" name="height-slider" min="64" max="2048" value="1024" step="8" oninput="updateHeightInput()"><br><br>
|
157 |
|
158 |
<label for="steps">Sampling Steps:</label>
|
159 |
<input type="number" id="steps" name="steps" value="35"><br><br>
|
|
|
197 |
steps = int(request.args.get("steps", 35))
|
198 |
cfg_scale = float(request.args.get("cfgs", 7))
|
199 |
sampler = request.args.get("sampler", "DPM++ 2M Karras")
|
|
|
200 |
strength = float(request.args.get("strength", 0.7))
|
201 |
+
seed = int(request.args.get("seed", -1))
|
202 |
width = int(request.args.get("width", 1024))
|
203 |
height = int(request.args.get("height", 1024))
|
204 |
|
205 |
# Call the query function to generate the image
|
206 |
image, error = query(prompt, negative_prompt, steps, cfg_scale, sampler, seed, strength, width, height)
|
207 |
+
|
208 |
if error:
|
209 |
+
return jsonify({"error": error}), 400
|
|
|
|
|
|
|
|
|
|
|
210 |
|
211 |
+
# Save the image to a BytesIO object and return it
|
212 |
+
img_bytes = io.BytesIO()
|
213 |
+
image.save(img_bytes, format='PNG')
|
214 |
+
img_bytes.seek(0)
|
215 |
+
return send_file(img_bytes, mimetype='image/png')
|
216 |
|
217 |
+
if __name__ == "__main__":
|
218 |
app.run(host='0.0.0.0', port=7860)
|