Update app.py
Browse files
app.py
CHANGED
|
@@ -47,7 +47,7 @@ ci = Interrogator(config)
|
|
| 47 |
|
| 48 |
def inference(input_images, mode, best_max_flavors):
|
| 49 |
# Process each image in the list and generate prompt results
|
| 50 |
-
|
| 51 |
for image_bytes in input_images:
|
| 52 |
image = Image.open(io.BytesIO(image_bytes)).convert('RGB')
|
| 53 |
if mode == 'best':
|
|
@@ -56,8 +56,9 @@ def inference(input_images, mode, best_max_flavors):
|
|
| 56 |
prompt_result = ci.interrogate_classic(image)
|
| 57 |
else:
|
| 58 |
prompt_result = ci.interrogate_fast(image)
|
| 59 |
-
|
| 60 |
-
return
|
|
|
|
| 61 |
|
| 62 |
|
| 63 |
title = """
|
|
@@ -150,7 +151,6 @@ a {text-decoration-line: underline; font-weight: 600;}
|
|
| 150 |
}
|
| 151 |
|
| 152 |
'''
|
| 153 |
-
|
| 154 |
with gr.Blocks(css=css) as block:
|
| 155 |
with gr.Column(elem_id="col-container"):
|
| 156 |
gr.HTML(title)
|
|
@@ -162,9 +162,10 @@ with gr.Blocks(css=css) as block:
|
|
| 162 |
|
| 163 |
submit_btn = gr.Button("Submit")
|
| 164 |
|
| 165 |
-
#
|
| 166 |
gallery = gr.Gallery(
|
| 167 |
-
label="Outputs", show_label=True, elem_id="gallery", object_fit="contain", height="auto"
|
|
|
|
| 168 |
)
|
| 169 |
|
| 170 |
with gr.Group(elem_id="share-btn-container"):
|
|
@@ -173,5 +174,5 @@ with gr.Blocks(css=css) as block:
|
|
| 173 |
gr.HTML(article)
|
| 174 |
submit_btn.click(fn=inference, inputs=[input_image,mode_input,flavor_input], outputs=[gallery], api_name="clipi2")
|
| 175 |
|
| 176 |
-
|
| 177 |
-
|
|
|
|
| 47 |
|
| 48 |
def inference(input_images, mode, best_max_flavors):
|
| 49 |
# Process each image in the list and generate prompt results
|
| 50 |
+
prompt_texts = []
|
| 51 |
for image_bytes in input_images:
|
| 52 |
image = Image.open(io.BytesIO(image_bytes)).convert('RGB')
|
| 53 |
if mode == 'best':
|
|
|
|
| 56 |
prompt_result = ci.interrogate_classic(image)
|
| 57 |
else:
|
| 58 |
prompt_result = ci.interrogate_fast(image)
|
| 59 |
+
prompt_texts.append(prompt_result['prompt']) # Extract the prompt text
|
| 60 |
+
return prompt_texts
|
| 61 |
+
|
| 62 |
|
| 63 |
|
| 64 |
title = """
|
|
|
|
| 151 |
}
|
| 152 |
|
| 153 |
'''
|
|
|
|
| 154 |
with gr.Blocks(css=css) as block:
|
| 155 |
with gr.Column(elem_id="col-container"):
|
| 156 |
gr.HTML(title)
|
|
|
|
| 162 |
|
| 163 |
submit_btn = gr.Button("Submit")
|
| 164 |
|
| 165 |
+
# Display the prompt texts
|
| 166 |
gallery = gr.Gallery(
|
| 167 |
+
label="Outputs", show_label=True, elem_id="gallery", object_fit="contain", height="auto",
|
| 168 |
+
src = "data:application/json,{{outputs['prompt_texts']}}"
|
| 169 |
)
|
| 170 |
|
| 171 |
with gr.Group(elem_id="share-btn-container"):
|
|
|
|
| 174 |
gr.HTML(article)
|
| 175 |
submit_btn.click(fn=inference, inputs=[input_image,mode_input,flavor_input], outputs=[gallery], api_name="clipi2")
|
| 176 |
|
| 177 |
+
block.queue(max_size=32,concurrency_count=10).launch(show_api=False)
|
| 178 |
+
|