scmlewis commited on
Commit
426cbf1
·
verified ·
1 Parent(s): cd8a6c1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -56
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: 900px !important;
72
  margin-left: auto !important;
73
  margin-right: auto !important;
74
- padding: 2rem 1rem;
75
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
76
  }
77
  .header-text {
78
- font-size: 2.4rem;
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: 1rem;
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 25px;
92
- border-radius: 10px;
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: 280px;
 
 
119
  }
120
  """
121
 
122
  with gr.Blocks(css=css_style) as demo:
123
- with gr.Row(elem_classes="app-container", equal_height=True):
124
- # Sidebar left
125
- with gr.Column(scale=3, elem_classes="sidebar"):
126
- gr.Markdown(
127
- """
128
- ### Usage Instructions
129
- - Upload a PNG input image.
130
- - Enter a prompt describing the edit.
131
- - Optionally enter your Gemini API key.
132
- - Click the Generate Edit button.
133
-
134
- ### API Tips
135
- - Use your own Gemini API key for best results.
136
- - Do not use NSFW images.
137
- - Outputs can include images or text messages.
138
-
139
- ### Links
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()