erfanasgari21 commited on
Commit
5439b53
·
verified ·
1 Parent(s): 791e174

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -34,7 +34,12 @@ def predict(image):
34
  output = model(image_tensor)
35
 
36
  wsr, hsr = output.squeeze().tolist()
37
- return f"Squish Ratio: (Width, Height)= ({wsr:.2f}, {hsr:.2f})"
 
 
 
 
 
38
 
39
  # Define the examples (provide paths to example images)
40
  examples = [
@@ -47,7 +52,7 @@ examples = [
47
  iface = gr.Interface(
48
  fn=predict,
49
  inputs=gr.Image(type="pil"),
50
- outputs="text",
51
  examples=examples,
52
  title="Deep Image Squish Predictor",
53
  description="Upload an image to see the predicted squish ratios."
 
34
  output = model(image_tensor)
35
 
36
  wsr, hsr = output.squeeze().tolist()
37
+ if(wsr < hsr):
38
+ height = int(height * wsr)
39
+ else:
40
+ width = int(width * hsr)
41
+ reconstructed_image = TF.resize(image, (height, width))
42
+ return f"Squish Ratio: (Width, Height)= ({wsr:.2f}, {hsr:.2f})", reconstructed_image
43
 
44
  # Define the examples (provide paths to example images)
45
  examples = [
 
52
  iface = gr.Interface(
53
  fn=predict,
54
  inputs=gr.Image(type="pil"),
55
+ outputs=[gr.Textbox(label="Prediction"), gr.Image(type="pil", label="Reconstructed Aspect-Ratio")],
56
  examples=examples,
57
  title="Deep Image Squish Predictor",
58
  description="Upload an image to see the predicted squish ratios."