Nymbo commited on
Commit
d10312c
·
verified ·
1 Parent(s): 027f804

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +126 -7
app.py CHANGED
@@ -71,14 +71,99 @@ def generate_video(
71
  generation_id = uuid.uuid4().hex[:8]
72
  print(f"Generation ID: {generation_id}")
73
 
74
- # Prepare parameters for the video generation request
75
- # Note: Different providers may have different parameter requirements
76
- parameters = {
77
- "prompt": prompt,
78
  "negative_prompt": negative_prompt,
79
- "num_frames": num_frames,
80
- "fps": fps,
81
- "width": width,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  "height": height,
83
  "num_inference_steps": num_inference_steps,
84
  "guidance_scale": guidance_scale,
@@ -284,6 +369,40 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme") as demo:
284
  lines=2
285
  )
286
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
287
  with gr.Row():
288
  width = gr.Slider(
289
  minimum=256,
 
71
  generation_id = uuid.uuid4().hex[:8]
72
  print(f"Generation ID: {generation_id}")
73
 
74
+ # Initial parameters dictionary - we'll customize it for each provider
75
+ base_parameters = {
 
 
76
  "negative_prompt": negative_prompt,
77
+ "num_inference_steps": num_inference_steps,
78
+ "guidance_scale": guidance_scale,
79
+ }
80
+
81
+ # Add seed if specified
82
+ if seed is not None and seed != -1:
83
+ base_parameters["seed"] = seed
84
+
85
+ # Provider-specific parameter handling
86
+ if provider == "hf-inference":
87
+ print("Using Hugging Face Inference API, adapting parameters...")
88
+ # HF Inference API supports these parameters
89
+ parameters = {
90
+ "negative_prompt": negative_prompt,
91
+ "num_inference_steps": num_inference_steps,
92
+ "guidance_scale": guidance_scale,
93
+ "num_frames": num_frames,
94
+ # HF Inference does NOT support fps
95
+ # "fps": fps,
96
+ "width": width,
97
+ "height": height,
98
+ }
99
+
100
+ # Add motion_bucket_id for SVD models if applicable
101
+ if "stable-video-diffusion" in model_to_use:
102
+ parameters["motion_bucket_id"] = motion_bucket_id
103
+
104
+ # Add seed if specified
105
+ if seed is not None and seed != -1:
106
+ parameters["seed"] = seed
107
+
108
+ elif provider == "fal-ai":
109
+ print("Using FalAI provider, adapting parameters...")
110
+ # According to Fal-AI API specification, only these parameters are supported
111
+ parameters = {
112
+ "negative_prompt": negative_prompt,
113
+ "num_frames": num_frames,
114
+ "num_inference_steps": num_inference_steps,
115
+ "guidance_scale": guidance_scale,
116
+ }
117
+
118
+ # Add seed if specified
119
+ if seed is not None and seed != -1:
120
+ parameters["seed"] = seed
121
+
122
+ # Note: width and height are not supported by Fal-AI's text_to_video API
123
+ print("Note: width and height parameters are not supported by Fal-AI and will be ignored")
124
+
125
+ elif provider == "novita":
126
+ print("Using Novita provider, adapting parameters...")
127
+ # Based on documentation, Novita uses specific parameters
128
+ parameters = {
129
+ "negative_prompt": negative_prompt,
130
+ "num_frames": num_frames,
131
+ "num_inference_steps": num_inference_steps,
132
+ "guidance_scale": guidance_scale,
133
+ "width": width,
134
+ "height": height
135
+ }
136
+
137
+ # Add seed if specified
138
+ if seed is not None and seed != -1:
139
+ parameters["seed"] = seed
140
+
141
+ elif provider == "replicate":
142
+ print("Using Replicate provider, adapting parameters...")
143
+ parameters = {
144
+ "negative_prompt": negative_prompt,
145
+ "num_frames": num_frames,
146
+ "num_inference_steps": num_inference_steps,
147
+ "guidance_scale": guidance_scale,
148
+ "width": width,
149
+ "height": height
150
+ }
151
+
152
+ # Add seed if specified
153
+ if seed is not None and seed != -1:
154
+ parameters["seed"] = seed
155
+
156
+ # Replicate supports fps in some models
157
+ if "stable-video-diffusion" in model_to_use:
158
+ parameters["fps"] = fps
159
+
160
+ else:
161
+ # Default parameters for any other provider
162
+ print(f"Using generic parameters for provider: {provider}")
163
+ parameters = base_parameters
164
+ parameters["num_frames"] = num_frames
165
+ parameters["width"] = width
166
+ parameters["height"] = height
167
  "height": height,
168
  "num_inference_steps": num_inference_steps,
169
  "guidance_scale": guidance_scale,
 
369
  lines=2
370
  )
371
 
372
+ with gr.Row():
373
+ num_inference_steps = gr.Slider(
374
+ minimum=1,
375
+ maximum=100,
376
+ value=25,
377
+ step=1,
378
+ label="Inference Steps"
379
+ )
380
+
381
+ guidance_scale = gr.Slider(
382
+ minimum=1.0,
383
+ maximum=20.0,
384
+ value=7.5,
385
+ step=0.5,
386
+ label="Guidance Scale"
387
+ )
388
+
389
+ with gr.Row():
390
+ motion_bucket_id = gr.Slider(
391
+ minimum=1,
392
+ maximum=255,
393
+ value=127,
394
+ step=1,
395
+ label="Motion Bucket ID (for SVD models)"
396
+ )
397
+
398
+ seed = gr.Slider(
399
+ minimum=-1,
400
+ maximum=2147483647,
401
+ value=-1,
402
+ step=1,
403
+ label="Seed (-1 for random)"
404
+ )
405
+
406
  with gr.Row():
407
  width = gr.Slider(
408
  minimum=256,