CHEN11102 commited on
Commit
55a04ca
·
verified ·
1 Parent(s): 61f3a37

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -17
app.py CHANGED
@@ -50,32 +50,31 @@ def resize_img(img1, img2_path):
50
  )
51
  img_to_resize.save('resized_img2.png')
52
 
53
- def predict(frame1, frame2, frame3, frame4, times_to_interpolate, model_name):
54
  model = models[model_name]
55
 
56
- frames = [resize(1080, frame) for frame in [frame1, frame2, frame3, frame4]]
 
57
 
58
- for i, frame in enumerate(frames):
59
- frame.save(f"test{i+1}.png")
60
 
61
- interpolated_frames = []
 
62
 
63
- for i in range(3):
64
- resize_img(f"test{i+1}.png", f"test{i+2}.png")
65
- input_frames = [f"test{i+1}.png", "resized_img2.png"]
66
- interpolated_frames.extend(
67
- util.interpolate_recursively_from_files(
68
- input_frames, times_to_interpolate, model))
69
 
70
- mediapy.write_video("out.mp4", interpolated_frames, fps=30)
71
  return "out.mp4"
72
 
73
  title = "Sports model"
74
  description = "Wechat:Liesle1"
75
  article = ""
76
  examples = [
77
- ['cat3.jpeg', 'cat4.jpeg', 'cat5.jpeg', 'cat6.jpeg', 2, model_names[0]],
78
- ['cat1.jpeg', 'cat2.jpeg', 'cat3.jpeg', 'cat4.jpeg', 2, model_names[1]],
79
  ]
80
 
81
  gr.Interface(
@@ -83,8 +82,6 @@ gr.Interface(
83
  inputs=[
84
  gr.Image(label="First Frame"),
85
  gr.Image(label="Second Frame"),
86
- gr.Image(label="Third Frame"),
87
- gr.Image(label="Fourth Frame"),
88
  gr.Number(label="Times to Interpolate", value=2),
89
  gr.Dropdown(label="Model", choices=model_names),
90
  ],
@@ -93,4 +90,4 @@ gr.Interface(
93
  description=description,
94
  article=article,
95
  examples=examples,
96
- ).launch()
 
50
  )
51
  img_to_resize.save('resized_img2.png')
52
 
53
+ def predict(frame1, frame2, times_to_interpolate, model_name):
54
  model = models[model_name]
55
 
56
+ frame1 = resize(1080, frame1)
57
+ frame2 = resize(1080, frame2)
58
 
59
+ frame1.save("test1.png")
60
+ frame2.save("test2.png")
61
 
62
+ resize_img("test1.png", "test2.png")
63
+ input_frames = ["test1.png", "resized_img2.png"]
64
 
65
+ frames = list(
66
+ util.interpolate_recursively_from_files(
67
+ input_frames, times_to_interpolate, model))
 
 
 
68
 
69
+ mediapy.write_video("out.mp4", frames, fps=30)
70
  return "out.mp4"
71
 
72
  title = "Sports model"
73
  description = "Wechat:Liesle1"
74
  article = ""
75
  examples = [
76
+ ['cat3.jpeg', 'cat4.jpeg', 2, model_names[0]],
77
+ ['cat1.jpeg', 'cat2.jpeg', 2, model_names[1]],
78
  ]
79
 
80
  gr.Interface(
 
82
  inputs=[
83
  gr.Image(label="First Frame"),
84
  gr.Image(label="Second Frame"),
 
 
85
  gr.Number(label="Times to Interpolate", value=2),
86
  gr.Dropdown(label="Model", choices=model_names),
87
  ],
 
90
  description=description,
91
  article=article,
92
  examples=examples,
93
+ ).launch()