SiyaYan commited on
Commit
b2963cf
Β·
verified Β·
1 Parent(s): 8b512dc

css update

Browse files
Files changed (1) hide show
  1. app.py +18 -41
app.py CHANGED
@@ -143,52 +143,29 @@ sample = ds[1]
143
  img, target = sample["image"], sample["remaining_lifespan"]
144
  img.save("example.jpg")
145
 
146
- cus="""
 
 
 
 
 
 
 
 
 
 
 
 
147
  #pred-box {
 
148
  display: flex;
149
- justify-content: center;
150
- align-items: center;
151
- height: 400px; /* match image height */
152
- font-size: 36px;
153
  font-weight: bold;
154
  color: #2E86AB;
155
  text-align: center;
156
  }
157
- """
158
-
159
- with gr.Blocks(css=cus) as demo:
160
- gr.Markdown("## Lifespan Predictor (Demo)")
161
-
162
- with gr.Row(equal_height=True): # πŸ‘ˆ this forces same height
163
- with gr.Column(scale=1):
164
- img_input = gr.Image(
165
- type="pil",
166
- sources=["upload", "webcam"],
167
- label="Face Photo",
168
- height=400, # set fixed height
169
- )
170
- # πŸ‘‡ Add example(s) here
171
- gr.Examples(
172
- examples=["example.jpg"], # can be local file, or multiple files
173
- inputs=img_input,
174
- label="Try an Example"
175
- )
176
- with gr.Column(scale=1):
177
- output = gr.HTML(label="Prediction", elem_id="pred-box")
178
-
179
- img_input.change(fn=predict, inputs=img_input, outputs=output)
180
-
181
- # demo.queue()
182
-
183
- # demo = gr.Interface(
184
- # fn=predict,
185
- # inputs=gr.Image(type="pil", sources=["upload", "webcam"], label="Face Photo"),
186
- # outputs=gr.HTML(label="Prediction"),
187
- # live=False,
188
- # title="Lifespan Predictor (Demo)",
189
- # description="Upload or take a face photo. Model predicts remaining lifespan (years).",
190
- # examples=[["example.jpg"]] # πŸ‘ˆ make sure example.jpg exists in repo
191
- # )
192
-
193
  if __name__ == "__main__":
194
  demo.launch()
 
143
  img, target = sample["image"], sample["remaining_lifespan"]
144
  img.save("example.jpg")
145
 
146
+
147
+ demo = gr.Interface(
148
+ fn=predict,
149
+ inputs=gr.Image(type="pil", sources=["upload", "webcam"], label="Face Photo"),
150
+ outputs=gr.HTML(label="Prediction", elem_id="pred-box"),
151
+ live=False,
152
+ title="Lifespan Predictor (Demo)",
153
+ description="Upload or take a face photo. Model predicts remaining lifespan (years).",
154
+ examples=[["example.jpg"]] # πŸ‘ˆ make sure example.jpg exists in repo
155
+ )
156
+
157
+ # Add CSS to fix height + center content
158
+ demo = demo.set_theme("default").css("""
159
  #pred-box {
160
+ height: 500px; /* fixed height to match image */
161
  display: flex;
162
+ justify-content: center; /* horizontal center */
163
+ align-items: center; /* vertical center */
164
+ font-size: 42px; /* bigger text */
 
165
  font-weight: bold;
166
  color: #2E86AB;
167
  text-align: center;
168
  }
169
+ """)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  if __name__ == "__main__":
171
  demo.launch()