Spaces:
Paused
Paused
Commit
·
ef13c0a
1
Parent(s):
2ec6a6a
Update app.py
Browse files
app.py
CHANGED
@@ -13,7 +13,7 @@ import spaces
|
|
13 |
import torch
|
14 |
from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
|
15 |
|
16 |
-
DESCRIPTION = '
|
17 |
if not torch.cuda.is_available():
|
18 |
DESCRIPTION += '\n<p>Running on CPU 🥶 This demo does not work on CPU.</p>'
|
19 |
|
@@ -21,6 +21,7 @@ MAX_NUM_FRAMES = int(os.getenv('MAX_NUM_FRAMES', '200'))
|
|
21 |
DEFAULT_NUM_FRAMES = min(MAX_NUM_FRAMES,
|
22 |
int(os.getenv('DEFAULT_NUM_FRAMES', '24')))
|
23 |
MAX_SEED = np.iinfo(np.int32).max
|
|
|
24 |
|
25 |
if torch.cuda.is_available():
|
26 |
pipe = DiffusionPipeline.from_pretrained('cerspense/zeroscope_v2_576w',
|
@@ -49,7 +50,12 @@ def to_video(frames: list[np.ndarray], fps: int) -> str:
|
|
49 |
|
50 |
@spaces.GPU
|
51 |
def generate(prompt: str, seed: int, num_frames: int,
|
52 |
-
num_inference_steps: int
|
|
|
|
|
|
|
|
|
|
|
53 |
generator = torch.Generator().manual_seed(seed)
|
54 |
frames = pipe(prompt,
|
55 |
num_inference_steps=num_inference_steps,
|
@@ -62,9 +68,11 @@ def generate(prompt: str, seed: int, num_frames: int,
|
|
62 |
|
63 |
with gr.Blocks(css='style.css') as demo:
|
64 |
gr.Markdown(DESCRIPTION)
|
65 |
-
gr.
|
66 |
-
|
67 |
-
|
|
|
|
|
68 |
with gr.Box():
|
69 |
with gr.Row():
|
70 |
prompt = gr.Text(label='Prompt',
|
@@ -101,6 +109,7 @@ with gr.Blocks(css='style.css') as demo:
|
|
101 |
seed,
|
102 |
num_frames,
|
103 |
num_inference_steps,
|
|
|
104 |
]
|
105 |
|
106 |
prompt.submit(
|
|
|
13 |
import torch
|
14 |
from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
|
15 |
|
16 |
+
DESCRIPTION = 'This space is an API service meant to be used by VideoChain and VideoQuest.\nWant to use this space for yourself? Please use the original code: [https://huggingface.co/spaces/hysts/zeroscope-v2](https://huggingface.co/spaces/hysts/zeroscope-v2)'
|
17 |
if not torch.cuda.is_available():
|
18 |
DESCRIPTION += '\n<p>Running on CPU 🥶 This demo does not work on CPU.</p>'
|
19 |
|
|
|
21 |
DEFAULT_NUM_FRAMES = min(MAX_NUM_FRAMES,
|
22 |
int(os.getenv('DEFAULT_NUM_FRAMES', '24')))
|
23 |
MAX_SEED = np.iinfo(np.int32).max
|
24 |
+
SECRET_TOKEN = os.getenv('SECRET_TOKEN', 'default_secret')
|
25 |
|
26 |
if torch.cuda.is_available():
|
27 |
pipe = DiffusionPipeline.from_pretrained('cerspense/zeroscope_v2_576w',
|
|
|
50 |
|
51 |
@spaces.GPU
|
52 |
def generate(prompt: str, seed: int, num_frames: int,
|
53 |
+
num_inference_steps: int,
|
54 |
+
secret_token: str = '') -> str:
|
55 |
+
if secret_token != SECRET_TOKEN:
|
56 |
+
raise gr.Error(
|
57 |
+
f'Invalid secret token. Please fork the original space if you want to use it for yourself.')
|
58 |
+
|
59 |
generator = torch.Generator().manual_seed(seed)
|
60 |
frames = pipe(prompt,
|
61 |
num_inference_steps=num_inference_steps,
|
|
|
68 |
|
69 |
with gr.Blocks(css='style.css') as demo:
|
70 |
gr.Markdown(DESCRIPTION)
|
71 |
+
secret_token = gr.Text(
|
72 |
+
label='Secret Token',
|
73 |
+
max_lines=1,
|
74 |
+
placeholder='Enter your secret token',
|
75 |
+
)
|
76 |
with gr.Box():
|
77 |
with gr.Row():
|
78 |
prompt = gr.Text(label='Prompt',
|
|
|
109 |
seed,
|
110 |
num_frames,
|
111 |
num_inference_steps,
|
112 |
+
secret_token,
|
113 |
]
|
114 |
|
115 |
prompt.submit(
|