Update app.py
Browse files
app.py
CHANGED
|
@@ -72,7 +72,7 @@ def get_seed(seed):
|
|
| 72 |
return random.randint(0, MAX_SEED)
|
| 73 |
|
| 74 |
@spaces.GPU(duration=60)
|
| 75 |
-
def generate(input=DEFAULT_INPUT, filter_input="", negative_input=DEFAULT_NEGATIVE_INPUT, model=DEFAULT_MODEL, height=DEFAULT_HEIGHT, width=DEFAULT_WIDTH, steps=1, guidance=0, number=1, seed=None):
|
| 76 |
|
| 77 |
repo = repo_customs[model or "Default"]
|
| 78 |
filter_input = filter_input or ""
|
|
@@ -133,15 +133,12 @@ def generate(input=DEFAULT_INPUT, filter_input="", negative_input=DEFAULT_NEGATI
|
|
| 133 |
|
| 134 |
print(nsfw_prediction)
|
| 135 |
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
buffer_data.extend([r, g, b, a])
|
| 143 |
-
|
| 144 |
-
buffer_json = json.dumps(buffer_data)
|
| 145 |
|
| 146 |
return image_paths, {item['label']: round(item['score'], 3) for item in nsfw_prediction}, buffer_json
|
| 147 |
|
|
@@ -164,6 +161,8 @@ with gr.Blocks(css=css) as main:
|
|
| 164 |
guidance = gr.Slider(minimum=0, maximum=100, step=0.1, value=5, label = "Guidance")
|
| 165 |
number = gr.Slider(minimum=1, maximum=4, step=1, value=1, label="Number")
|
| 166 |
seed = gr.Textbox(lines=1, value="", label="Seed (Blank for random)")
|
|
|
|
|
|
|
| 167 |
submit = gr.Button("▶")
|
| 168 |
maintain = gr.Button("☁️")
|
| 169 |
|
|
@@ -172,7 +171,7 @@ with gr.Blocks(css=css) as main:
|
|
| 172 |
output_2 = gr.Label()
|
| 173 |
output_3 = gr.Textbox(lines=1, value="", label="Buffer")
|
| 174 |
|
| 175 |
-
submit.click(generate, inputs=[input, filter_input, negative_input, model, height, width, steps, guidance, number, seed], outputs=[output, output_2], queue=False)
|
| 176 |
maintain.click(cloud, inputs=[], outputs=[], queue=False)
|
| 177 |
|
| 178 |
main.launch(show_api=True)
|
|
|
|
| 72 |
return random.randint(0, MAX_SEED)
|
| 73 |
|
| 74 |
@spaces.GPU(duration=60)
|
| 75 |
+
def generate(input=DEFAULT_INPUT, filter_input="", negative_input=DEFAULT_NEGATIVE_INPUT, model=DEFAULT_MODEL, height=DEFAULT_HEIGHT, width=DEFAULT_WIDTH, steps=1, guidance=0, number=1, seed=None, height_buffer=DEFAULT_HEIGHT, width_buffer=DEFAULT_WIDTH):
|
| 76 |
|
| 77 |
repo = repo_customs[model or "Default"]
|
| 78 |
filter_input = filter_input or ""
|
|
|
|
| 133 |
|
| 134 |
print(nsfw_prediction)
|
| 135 |
|
| 136 |
+
buffer_image = images[0].convert("RGBA").resize((width_buffer, height_buffer))
|
| 137 |
+
|
| 138 |
+
image_array = np.array(buffer_image)
|
| 139 |
+
pixel_data = image_array.flatten().tolist()
|
| 140 |
+
|
| 141 |
+
buffer_json = json.dumps(pixel_data)
|
|
|
|
|
|
|
|
|
|
| 142 |
|
| 143 |
return image_paths, {item['label']: round(item['score'], 3) for item in nsfw_prediction}, buffer_json
|
| 144 |
|
|
|
|
| 161 |
guidance = gr.Slider(minimum=0, maximum=100, step=0.1, value=5, label = "Guidance")
|
| 162 |
number = gr.Slider(minimum=1, maximum=4, step=1, value=1, label="Number")
|
| 163 |
seed = gr.Textbox(lines=1, value="", label="Seed (Blank for random)")
|
| 164 |
+
height_buffer = gr.Slider(minimum=1, maximum=2160, step=1, value=DEFAULT_HEIGHT, label="Buffer Height")
|
| 165 |
+
width_buffer = gr.Slider(minimum=1, maximum=2160, step=1, value=DEFAULT_WIDTH, label="uffer Width")
|
| 166 |
submit = gr.Button("▶")
|
| 167 |
maintain = gr.Button("☁️")
|
| 168 |
|
|
|
|
| 171 |
output_2 = gr.Label()
|
| 172 |
output_3 = gr.Textbox(lines=1, value="", label="Buffer")
|
| 173 |
|
| 174 |
+
submit.click(generate, inputs=[input, filter_input, negative_input, model, height, width, steps, guidance, number, seed, height_buffer, width_buffer], outputs=[output, output_2], queue=False)
|
| 175 |
maintain.click(cloud, inputs=[], outputs=[], queue=False)
|
| 176 |
|
| 177 |
main.launch(show_api=True)
|