ihabooe commited on
Commit
78d7262
·
verified ·
1 Parent(s): c0fb104

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +78 -26
app.py CHANGED
@@ -90,71 +90,123 @@ def process(image, progress=gr.Progress()):
90
  return output_array, gr.update(visible=True, value=filepath, interactive=True)
91
 
92
  # Gradio interface setup
93
- title = "Background Removal"
94
- description = r"""<br>"""
 
 
 
 
 
 
 
95
 
96
  # Create the Gradio interface
97
  with gr.Blocks(css="""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  .download-btn {
99
- background-color: #4CAF50 !important;
100
  color: white !important;
101
  border: none !important;
102
- padding: 10px 24px !important;
103
  text-align: center !important;
104
  text-decoration: none !important;
105
  display: inline-block !important;
106
  font-size: 16px !important;
107
- margin: 10px 0 !important;
108
  cursor: pointer !important;
109
- border-radius: 4px !important;
110
- transition: background-color 0.3s !important;
 
111
  }
 
112
  .download-btn:hover {
113
- background-color: #45a049 !important;
 
 
114
  }
115
- /* Style the file download component to look like a button */
 
116
  .download-container [data-testid="file"] {
117
  display: block !important;
118
  }
 
119
  .download-container [data-testid="file"] > div:first-child {
120
- display: none !important; /* Hide the file icon */
121
  }
 
122
  .download-container [data-testid="file"] > div:last-child {
123
  margin-left: 0 !important;
124
  }
 
125
  .download-container [data-testid="file"] button {
126
- background-color: #4CAF50 !important;
127
  color: white !important;
128
  border: none !important;
129
- padding: 10px 24px !important;
130
  text-align: center !important;
131
- text-decoration: none !important;
132
- display: inline-block !important;
133
  font-size: 16px !important;
134
- margin: 10px 0 !important;
135
  cursor: pointer !important;
136
- border-radius: 4px !important;
137
- transition: background-color 0.3s !important;
138
  width: 100% !important;
 
139
  }
 
140
  .download-container [data-testid="file"] button:hover {
141
- background-color: #45a049 !important;
 
 
 
 
 
 
 
 
 
 
142
  }
143
  """) as demo:
144
- gr.Markdown(f"# {title}")
145
  gr.Markdown(description)
146
 
147
- with gr.Row():
148
- with gr.Column(scale=1):
149
- input_image = gr.Image(type="numpy", label="Upload Image")
 
 
 
 
150
 
151
- with gr.Column(scale=1):
152
- output_image = gr.Image(type="numpy", label="Result")
 
 
 
 
153
 
154
- # Direct download file component styled as a button
155
  with gr.Row(elem_classes="download-container"):
156
  download_file = gr.File(
157
- label="",
158
  file_count="single",
159
  interactive=True,
160
  visible=False
 
90
  return output_array, gr.update(visible=True, value=filepath, interactive=True)
91
 
92
  # Gradio interface setup
93
+ title = "Background Removal Tool"
94
+ description = """
95
+ <div style="text-align: center; max-width: 800px; margin: 0 auto; padding: 20px;">
96
+ <h1 style="color: #2D3748; font-size: 2.5em; margin-bottom: 20px;">Professional Background Removal</h1>
97
+ <p style="color: #4A5568; font-size: 1.2em; margin-bottom: 20px;">
98
+ Upload your image and get instant background removal using AI technology.
99
+ </p>
100
+ </div>
101
+ """
102
 
103
  # Create the Gradio interface
104
  with gr.Blocks(css="""
105
+ /* Global styles */
106
+ .container {
107
+ max-width: 1200px;
108
+ margin: 0 auto;
109
+ padding: 2rem;
110
+ }
111
+
112
+ /* Card styling */
113
+ .input-card, .output-card {
114
+ background-color: white;
115
+ border-radius: 10px;
116
+ padding: 20px;
117
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
118
+ transition: transform 0.2s;
119
+ }
120
+
121
+ .input-card:hover, .output-card:hover {
122
+ transform: translateY(-5px);
123
+ }
124
+
125
+ /* Button styling */
126
  .download-btn {
127
+ background-color: #4F46E5 !important;
128
  color: white !important;
129
  border: none !important;
130
+ padding: 12px 28px !important;
131
  text-align: center !important;
132
  text-decoration: none !important;
133
  display: inline-block !important;
134
  font-size: 16px !important;
135
+ margin: 15px 0 !important;
136
  cursor: pointer !important;
137
+ border-radius: 8px !important;
138
+ transition: all 0.3s ease !important;
139
+ font-weight: 600 !important;
140
  }
141
+
142
  .download-btn:hover {
143
+ background-color: #4338CA !important;
144
+ transform: translateY(-2px);
145
+ box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3) !important;
146
  }
147
+
148
+ /* File download styling */
149
  .download-container [data-testid="file"] {
150
  display: block !important;
151
  }
152
+
153
  .download-container [data-testid="file"] > div:first-child {
154
+ display: none !important;
155
  }
156
+
157
  .download-container [data-testid="file"] > div:last-child {
158
  margin-left: 0 !important;
159
  }
160
+
161
  .download-container [data-testid="file"] button {
162
+ background-color: #4F46E5 !important;
163
  color: white !important;
164
  border: none !important;
165
+ padding: 12px 28px !important;
166
  text-align: center !important;
 
 
167
  font-size: 16px !important;
168
+ margin: 15px 0 !important;
169
  cursor: pointer !important;
170
+ border-radius: 8px !important;
171
+ transition: all 0.3s ease !important;
172
  width: 100% !important;
173
+ font-weight: 600 !important;
174
  }
175
+
176
  .download-container [data-testid="file"] button:hover {
177
+ background-color: #4338CA !important;
178
+ transform: translateY(-2px);
179
+ box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3) !important;
180
+ }
181
+
182
+ /* Label styling */
183
+ label {
184
+ font-weight: 600 !important;
185
+ color: #2D3748 !important;
186
+ font-size: 1.1em !important;
187
+ margin-bottom: 8px !important;
188
  }
189
  """) as demo:
 
190
  gr.Markdown(description)
191
 
192
+ with gr.Row(equal_height=True):
193
+ with gr.Column(scale=1, elem_classes="input-card"):
194
+ input_image = gr.Image(
195
+ type="numpy",
196
+ label="Upload Your Image",
197
+ elem_id="input-image"
198
+ )
199
 
200
+ with gr.Column(scale=1, elem_classes="output-card"):
201
+ output_image = gr.Image(
202
+ type="numpy",
203
+ label="Result",
204
+ elem_id="output-image"
205
+ )
206
 
 
207
  with gr.Row(elem_classes="download-container"):
208
  download_file = gr.File(
209
+ label="",
210
  file_count="single",
211
  interactive=True,
212
  visible=False