Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -68,19 +68,19 @@ def process_image_and_prompt(pil_image, prompt, api_key):
|
|
| 68 |
|
| 69 |
css_style = """
|
| 70 |
.app-container {
|
| 71 |
-
max-width:
|
| 72 |
margin-left: auto !important;
|
| 73 |
margin-right: auto !important;
|
| 74 |
-
padding:
|
| 75 |
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 76 |
}
|
| 77 |
.header-text {
|
| 78 |
-
font-size: 2.
|
| 79 |
font-weight: 900;
|
| 80 |
background: linear-gradient(90deg, #FF6A00, #EE0979);
|
| 81 |
-webkit-background-clip: text;
|
| 82 |
-webkit-text-fill-color: transparent;
|
| 83 |
-
margin-bottom:
|
| 84 |
text-align: center;
|
| 85 |
}
|
| 86 |
.gradient-button {
|
|
@@ -88,24 +88,14 @@ css_style = """
|
|
| 88 |
border: none;
|
| 89 |
color: white;
|
| 90 |
font-weight: 700;
|
| 91 |
-
padding: 12px
|
| 92 |
-
border-radius:
|
| 93 |
cursor: pointer;
|
| 94 |
transition: background 0.5s ease;
|
| 95 |
}
|
| 96 |
.gradient-button:hover {
|
| 97 |
background: linear-gradient(90deg, #EE0979, #FF6A00);
|
| 98 |
}
|
| 99 |
-
.sidebar {
|
| 100 |
-
background: #f7f7f7;
|
| 101 |
-
padding: 20px;
|
| 102 |
-
border-radius: 12px;
|
| 103 |
-
box-shadow: 0 2px 7px rgb(0 0 0 / 0.08);
|
| 104 |
-
max-width: 280px;
|
| 105 |
-
}
|
| 106 |
-
.sidebar h3 {
|
| 107 |
-
margin-top: 0;
|
| 108 |
-
}
|
| 109 |
main-content {
|
| 110 |
display: flex;
|
| 111 |
gap: 2rem;
|
|
@@ -115,49 +105,29 @@ main-content {
|
|
| 115 |
flex: 1;
|
| 116 |
}
|
| 117 |
.output-gallery {
|
| 118 |
-
min-height:
|
|
|
|
|
|
|
| 119 |
}
|
| 120 |
"""
|
| 121 |
|
| 122 |
with gr.Blocks(css=css_style) as demo:
|
| 123 |
-
with gr.
|
| 124 |
-
|
| 125 |
-
with gr.
|
| 126 |
-
gr.
|
| 127 |
-
"""
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
- [Duplicate this repo](https://huggingface.co/spaces/ameerazam08/Gemini-Image-Edit?duplicate=true)
|
| 141 |
-
- [Get API Key](https://aistudio.google.com/apikey)
|
| 142 |
-
- Follow the author on [Twitter](https://x.com/Ameerazam18)
|
| 143 |
-
"""
|
| 144 |
-
)
|
| 145 |
-
# Main panel right
|
| 146 |
-
with gr.Column(scale=7):
|
| 147 |
-
gr.Markdown("<div class='header-text'>Gemini for Image Editing</div>")
|
| 148 |
-
with gr.Row():
|
| 149 |
-
with gr.Column():
|
| 150 |
-
image_input = gr.Image(type="pil", label="Upload PNG Image", image_mode="RGBA")
|
| 151 |
-
prompt_input = gr.Textbox(label="Edit Prompt", placeholder="Describe how to edit the image", lines=2)
|
| 152 |
-
api_key_input = gr.Textbox(label="Gemini API Key (optional)", placeholder="Enter your Gemini API key here", type="password")
|
| 153 |
-
submit_btn = gr.Button("Generate Edit", elem_classes="gradient-button")
|
| 154 |
-
with gr.Column():
|
| 155 |
-
gallery_output = gr.Gallery(label="Generated Image", elem_classes="output-gallery", height=280)
|
| 156 |
-
text_output = gr.Textbox(label="Generation Status or Text Output", interactive=False)
|
| 157 |
-
submit_btn.click(
|
| 158 |
-
fn=process_image_and_prompt,
|
| 159 |
-
inputs=[image_input, prompt_input, api_key_input],
|
| 160 |
-
outputs=[gallery_output, text_output]
|
| 161 |
-
)
|
| 162 |
|
| 163 |
demo.queue(max_size=50).launch()
|
|
|
|
| 68 |
|
| 69 |
css_style = """
|
| 70 |
.app-container {
|
| 71 |
+
max-width: 1000px !important;
|
| 72 |
margin-left: auto !important;
|
| 73 |
margin-right: auto !important;
|
| 74 |
+
padding: 1.5rem 1rem;
|
| 75 |
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 76 |
}
|
| 77 |
.header-text {
|
| 78 |
+
font-size: 2.6rem;
|
| 79 |
font-weight: 900;
|
| 80 |
background: linear-gradient(90deg, #FF6A00, #EE0979);
|
| 81 |
-webkit-background-clip: text;
|
| 82 |
-webkit-text-fill-color: transparent;
|
| 83 |
+
margin-bottom: 1.2rem;
|
| 84 |
text-align: center;
|
| 85 |
}
|
| 86 |
.gradient-button {
|
|
|
|
| 88 |
border: none;
|
| 89 |
color: white;
|
| 90 |
font-weight: 700;
|
| 91 |
+
padding: 12px 30px;
|
| 92 |
+
border-radius: 12px;
|
| 93 |
cursor: pointer;
|
| 94 |
transition: background 0.5s ease;
|
| 95 |
}
|
| 96 |
.gradient-button:hover {
|
| 97 |
background: linear-gradient(90deg, #EE0979, #FF6A00);
|
| 98 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
main-content {
|
| 100 |
display: flex;
|
| 101 |
gap: 2rem;
|
|
|
|
| 105 |
flex: 1;
|
| 106 |
}
|
| 107 |
.output-gallery {
|
| 108 |
+
min-height: 480px;
|
| 109 |
+
max-height: 480px;
|
| 110 |
+
overflow: visible !important;
|
| 111 |
}
|
| 112 |
"""
|
| 113 |
|
| 114 |
with gr.Blocks(css=css_style) as demo:
|
| 115 |
+
with gr.Column(elem_classes="app-container"):
|
| 116 |
+
gr.Markdown("<div class='header-text'>Image Editor (Powered by Gemini)</div>")
|
| 117 |
+
with gr.Row(elem_classes="main-content"):
|
| 118 |
+
with gr.Column(elem_classes="column"):
|
| 119 |
+
image_input = gr.Image(type="pil", label="Upload PNG Image", image_mode="RGBA")
|
| 120 |
+
prompt_input = gr.Textbox(label="Edit Prompt", placeholder="Describe how to edit the image", lines=2)
|
| 121 |
+
api_key_input = gr.Textbox(label="Gemini API Key (optional)", placeholder="Enter your Gemini API key here", type="password")
|
| 122 |
+
submit_btn = gr.Button("Generate Edit", elem_classes="gradient-button")
|
| 123 |
+
with gr.Column(elem_classes="column"):
|
| 124 |
+
gallery_output = gr.Gallery(label="Generated Image", elem_classes="output-gallery")
|
| 125 |
+
text_output = gr.Textbox(label="Generation Status or Text Output", interactive=False, lines=6)
|
| 126 |
+
|
| 127 |
+
submit_btn.click(
|
| 128 |
+
fn=process_image_and_prompt,
|
| 129 |
+
inputs=[image_input, prompt_input, api_key_input],
|
| 130 |
+
outputs=[gallery_output, text_output]
|
| 131 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
|
| 133 |
demo.queue(max_size=50).launch()
|