Spaces:
Sleeping
Sleeping
Arjun Singh
commited on
Commit
·
18bd6bb
1
Parent(s):
5b51ea4
One output
Browse files
app.py
CHANGED
|
@@ -39,14 +39,10 @@ def call_api_and_generate_image(negative_prompt, positive_prompt,seed, source_im
|
|
| 39 |
|
| 40 |
result = resp.json()
|
| 41 |
base64_initial = result['result'][0]['data']
|
| 42 |
-
|
| 43 |
-
|
| 44 |
|
| 45 |
-
|
| 46 |
-
final_image_data = base64.b64decode(base64_final)
|
| 47 |
-
final_image = Image.open(io.BytesIO(final_image_data))
|
| 48 |
-
|
| 49 |
-
return initial_image,final_image
|
| 50 |
|
| 51 |
def generate_image(positive_prompt, negative_prompt,source_image):
|
| 52 |
seed = numpy.random.randint(0, 2**32 - 1)
|
|
@@ -56,7 +52,7 @@ def generate_image(positive_prompt, negative_prompt,source_image):
|
|
| 56 |
return None, f"Error: {str(e)}"
|
| 57 |
|
| 58 |
def clear_fields():
|
| 59 |
-
return "", "", None
|
| 60 |
|
| 61 |
with gr.Blocks(theme='freddyaboulton/test-blue') as demo:
|
| 62 |
gr.Markdown("<center><h2>Arjun's Image Generator</h2></center>")
|
|
@@ -69,10 +65,9 @@ with gr.Blocks(theme='freddyaboulton/test-blue') as demo:
|
|
| 69 |
submit_btn = gr.Button(value="Submit", elem_id="generate_button", variant="primary", size="sm")
|
| 70 |
clear_btn = gr.ClearButton(value="Clear Question and AI Response", elem_id="clear_button", variant="secondary", size="sm")
|
| 71 |
gr.Markdown("<center><h3>AI Response</h3></center>")
|
| 72 |
-
|
| 73 |
-
final_image_output = gr.Image(type="pil", label="Final Image After Face Swap")
|
| 74 |
|
| 75 |
-
submit_btn.click(fn=generate_image, inputs = [prompt,neg_prompt,source_image], outputs=[
|
| 76 |
-
clear_btn.click(fn=clear_fields,outputs=[prompt,neg_prompt,
|
| 77 |
|
| 78 |
demo.launch()
|
|
|
|
| 39 |
|
| 40 |
result = resp.json()
|
| 41 |
base64_initial = result['result'][0]['data']
|
| 42 |
+
image_data = base64.b64decode(base64_initial)
|
| 43 |
+
image_output = Image.open(io.BytesIO(image_data))
|
| 44 |
|
| 45 |
+
return image_output
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
def generate_image(positive_prompt, negative_prompt,source_image):
|
| 48 |
seed = numpy.random.randint(0, 2**32 - 1)
|
|
|
|
| 52 |
return None, f"Error: {str(e)}"
|
| 53 |
|
| 54 |
def clear_fields():
|
| 55 |
+
return "", "", None # Clear prompt and outputs
|
| 56 |
|
| 57 |
with gr.Blocks(theme='freddyaboulton/test-blue') as demo:
|
| 58 |
gr.Markdown("<center><h2>Arjun's Image Generator</h2></center>")
|
|
|
|
| 65 |
submit_btn = gr.Button(value="Submit", elem_id="generate_button", variant="primary", size="sm")
|
| 66 |
clear_btn = gr.ClearButton(value="Clear Question and AI Response", elem_id="clear_button", variant="secondary", size="sm")
|
| 67 |
gr.Markdown("<center><h3>AI Response</h3></center>")
|
| 68 |
+
image_output = gr.Image(type="pil", label="Final Generated Image")
|
|
|
|
| 69 |
|
| 70 |
+
submit_btn.click(fn=generate_image, inputs = [prompt,neg_prompt,source_image], outputs=[image_output])
|
| 71 |
+
clear_btn.click(fn=clear_fields,outputs=[prompt,neg_prompt,image_output])
|
| 72 |
|
| 73 |
demo.launch()
|