tedlasai commited on
Commit
f3bf944
Β·
1 Parent(s): 6a2f159

removed orientation mode

Browse files
Files changed (1) hide show
  1. gradio/app.py +6 -34
gradio/app.py CHANGED
@@ -11,7 +11,7 @@ from diffusers.utils import export_to_video
11
  from inference import load_model, inference_on_image
12
 
13
  # -----------------------
14
- # 1. Load your model here
15
  # -----------------------
16
  args = argparse.Namespace()
17
  args.blur2vid_hf_repo_path = "tedlasai/blur2vid"
@@ -19,8 +19,6 @@ args.pretrained_model_path = "THUDM/CogVideoX-2b"
19
  args.model_config_path = "training/configs/outsidephotos.yaml"
20
  args.video_width = 1280
21
  args.video_height = 720
22
- # args.video_width = 960
23
- # args.video_height = 540
24
  args.seed = None
25
 
26
  pipe, model_config = load_model(args)
@@ -29,8 +27,8 @@ OUTPUT_DIR = Path("/tmp/generated_videos")
29
  OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
30
 
31
 
32
- @spaces.GPU(timeout=300)
33
- def generate_video_from_image(image: Image.Image, interval_key: str, orientation_mode: str, num_inference_steps: int) -> str:
34
  """
35
  Wrapper for Gradio. Takes an image and returns a video path.
36
  """
@@ -43,19 +41,6 @@ def generate_video_from_image(image: Image.Image, interval_key: str, orientation
43
  print("Device:", torch.cuda.get_device_name(0))
44
  print("bf16 supported:", torch.cuda.is_bf16_supported())
45
 
46
- if orientation_mode == "Landscape (1280Γ—720)":
47
- print("Chosing resolution 1280Γ—720 (landscape)")
48
- args.video_width = 1280
49
- args.video_height = 720
50
- elif orientation_mode == "Portrait (720Γ—1280)":
51
- print("Choosing resolution 720Γ—1280 (portrait)")
52
- args.video_height = 1280
53
- args.video_width = 720
54
- else:
55
- print("Unknown orientation mode", orientation_mode, "defaulting to 1280x720")
56
- args.video_width = 1280
57
- args.video_height = 720
58
-
59
  args.num_inference_steps = num_inference_steps
60
 
61
  video_id = uuid.uuid4().hex
@@ -84,7 +69,8 @@ with gr.Blocks(css="footer {visibility: hidden}") as demo:
84
  - 🌐 **Project page:** <https://blur2vid.github.io/>
85
  - πŸ’» **Code:** <https://github.com/tedlasai/blur2vid/>
86
 
87
- Upload a blurry image and the model will generate a short video containing the recovered motion depending on your selection.
 
88
  """
89
  )
90
 
@@ -104,20 +90,6 @@ with gr.Blocks(css="footer {visibility: hidden}") as demo:
104
  interactive=True,
105
  )
106
 
107
- with gr.Row():
108
- mode_choice = gr.Radio(
109
- label="Orientation",
110
- choices=["Landscape (1280Γ—720)", "Portrait (720Γ—1280)"],
111
- value="Landscape (1280Γ—720)",
112
- interactive=True,
113
- )
114
-
115
- gr.Markdown(
116
- "<span style='font-size: 12px; color: gray;'>"
117
- "Note: Model was trained on 1280Γ—720 (Landscape). Portrait mode will degrade performance."
118
- "</span>"
119
- )
120
-
121
  num_inference_steps = gr.Slider(
122
  label="Number of inference steps",
123
  minimum=4,
@@ -139,7 +111,7 @@ with gr.Blocks(css="footer {visibility: hidden}") as demo:
139
 
140
  generate_btn.click(
141
  fn=generate_video_from_image,
142
- inputs=[image_in, tense_choice, mode_choice, num_inference_steps], # ← include tense_choice!
143
  outputs=video_out,
144
  api_name="predict",
145
  )
 
11
  from inference import load_model, inference_on_image
12
 
13
  # -----------------------
14
+ # 1. Load model
15
  # -----------------------
16
  args = argparse.Namespace()
17
  args.blur2vid_hf_repo_path = "tedlasai/blur2vid"
 
19
  args.model_config_path = "training/configs/outsidephotos.yaml"
20
  args.video_width = 1280
21
  args.video_height = 720
 
 
22
  args.seed = None
23
 
24
  pipe, model_config = load_model(args)
 
27
  OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
28
 
29
 
30
+ @spaces.GPU(timeout=300, duration=200)
31
+ def generate_video_from_image(image: Image.Image, interval_key: str, num_inference_steps: int) -> str:
32
  """
33
  Wrapper for Gradio. Takes an image and returns a video path.
34
  """
 
41
  print("Device:", torch.cuda.get_device_name(0))
42
  print("bf16 supported:", torch.cuda.is_bf16_supported())
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  args.num_inference_steps = num_inference_steps
45
 
46
  video_id = uuid.uuid4().hex
 
69
  - 🌐 **Project page:** <https://blur2vid.github.io/>
70
  - πŸ’» **Code:** <https://github.com/tedlasai/blur2vid/>
71
 
72
+ Upload a blurry image and the model will generate a short video showing the recovered motion based on your selection.
73
+ Note: The image will be resized to 1280Γ—720. We recommend uploading landscape-oriented images.
74
  """
75
  )
76
 
 
90
  interactive=True,
91
  )
92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  num_inference_steps = gr.Slider(
94
  label="Number of inference steps",
95
  minimum=4,
 
111
 
112
  generate_btn.click(
113
  fn=generate_video_from_image,
114
+ inputs=[image_in, tense_choice, num_inference_steps],
115
  outputs=video_out,
116
  api_name="predict",
117
  )