penpen commited on
Commit
5d99f2e
·
1 Parent(s): a18f8a1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -10
app.py CHANGED
@@ -145,7 +145,6 @@ def age_filter(image, input_age, output_age):
145
  input_image = transform_resize(image=np.array(image))['image']/255
146
 
147
 
148
- #input_image=(dataset[0]['normalized_input_image'])
149
  age_map1 = torch.full((1, 512, 512), input_age / 100)
150
  age_map2 = torch.full((1, 512, 512), output_age / 100)
151
 
@@ -175,26 +174,19 @@ def crop_and_process_image(input_img,input_age,output_ag):
175
  # Return the output
176
  return output
177
 
178
- # Define the input image component with the crop tool
179
 
180
- # Define the output image component
181
  output_image = gr.Image(label="Output Image", type="pil")
182
 
183
-
184
  input_age = gr.Slider(label="Current Age")
185
  output_age = gr.Slider(label="Desired Age")
186
 
187
 
188
- # Define the function to be called when the button is pressed
189
  def process_image(input_img,input_age,output_age):
190
- # Convert the input image to a PyTorch tensor
191
 
192
- # Call the crop_and_process_image function
193
  output = crop_and_process_image(input_img,input_age,output_age)
194
 
195
- # Convert the output tensor to a NumPy array and return it
196
  output = Image.fromarray(output)
197
- output.show()
198
  return output
199
 
200
  description="Enter age of input image and desired age. Crop out face. Better results on high resolution."
@@ -202,4 +194,4 @@ description="Enter age of input image and desired age. Crop out face. Better res
202
 
203
 
204
  # Create the Gradio interface
205
- gr.Interface(fn=process_image, inputs=[gr.Image(source="upload", type="filepath", label="init_img | 512*512 px"),input_age,output_age], outputs=output_image,description=description, title="Age Transformation").launch(debug=True)
 
145
  input_image = transform_resize(image=np.array(image))['image']/255
146
 
147
 
 
148
  age_map1 = torch.full((1, 512, 512), input_age / 100)
149
  age_map2 = torch.full((1, 512, 512), output_age / 100)
150
 
 
174
  # Return the output
175
  return output
176
 
177
+ input_image = gr.Image(label="Input Image", interactive=True)
178
 
 
179
  output_image = gr.Image(label="Output Image", type="pil")
180
 
 
181
  input_age = gr.Slider(label="Current Age")
182
  output_age = gr.Slider(label="Desired Age")
183
 
184
 
 
185
  def process_image(input_img,input_age,output_age):
 
186
 
 
187
  output = crop_and_process_image(input_img,input_age,output_age)
188
 
 
189
  output = Image.fromarray(output)
 
190
  return output
191
 
192
  description="Enter age of input image and desired age. Crop out face. Better results on high resolution."
 
194
 
195
 
196
  # Create the Gradio interface
197
+ gr.Interface(fn=process_image, inputs=[input_image,input_age,output_age], outputs=output_image,description=description, title="Age Transformation").launch(debug=True)