Tonic commited on
Commit
775329e
1 Parent(s): dc2eed4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -5,6 +5,7 @@ import os
5
  from glob import glob
6
  from pathlib import Path
7
  from typing import Optional
 
8
  from diffusers import StableVideoDiffusionPipeline
9
  from diffusers.utils import load_image, export_to_video
10
  from PIL import Image
@@ -18,9 +19,18 @@ title = '''# 👋🏻Welcome to Tonic's🌟🎥StableVideo XT-1-1
18
  Join us : 🌟TeamTonic🌟 is always making cool demos! Join our active builder's🛠️community 👻 [![Join us on Discord](https://img.shields.io/discord/1109943800132010065?label=Discord&logo=discord&style=flat-square)](https://discord.gg/GWpVpekp) On 🤗Huggingface: [TeamTonic](https://huggingface.co/TeamTonic) & [MultiTransformer](https://huggingface.co/MultiTransformer) On 🌐Github: [Tonic-AI](https://github.com/tonic-ai) & contribute to 🌟 [SciTonic](https://github.com/Tonic-AI/scitonic) 🤗Big thanks to Yuvi Sharma and all the folks at huggingface for the community grant 🤗
19
  '''
20
 
 
 
 
 
 
 
 
 
 
21
 
22
  pipe = StableVideoDiffusionPipeline.from_pretrained(
23
- "stabilityai/stable-video-diffusion-img2vid-xt-1-1", torch_dtype=torch.float16, variant="fp16"
24
  )
25
  pipe.to("cuda")
26
  pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
 
5
  from glob import glob
6
  from pathlib import Path
7
  from typing import Optional
8
+ from huggingface_hub import HfFolder
9
  from diffusers import StableVideoDiffusionPipeline
10
  from diffusers.utils import load_image, export_to_video
11
  from PIL import Image
 
19
  Join us : 🌟TeamTonic🌟 is always making cool demos! Join our active builder's🛠️community 👻 [![Join us on Discord](https://img.shields.io/discord/1109943800132010065?label=Discord&logo=discord&style=flat-square)](https://discord.gg/GWpVpekp) On 🤗Huggingface: [TeamTonic](https://huggingface.co/TeamTonic) & [MultiTransformer](https://huggingface.co/MultiTransformer) On 🌐Github: [Tonic-AI](https://github.com/tonic-ai) & contribute to 🌟 [SciTonic](https://github.com/Tonic-AI/scitonic) 🤗Big thanks to Yuvi Sharma and all the folks at huggingface for the community grant 🤗
20
  '''
21
 
22
+ # Load the API token from an environment variable
23
+ hf_token = os.getenv("HF_TOKEN")
24
+
25
+ # If the token is not found, raise an error or handle it appropriately
26
+ if not hf_token:
27
+ raise ValueError("Hugging Face token not found. Please set the HF_TOKEN environment variable.")
28
+
29
+ # Use the token for authentication
30
+ HfFolder.save_token(hf_token)
31
 
32
  pipe = StableVideoDiffusionPipeline.from_pretrained(
33
+ "stabilityai/stable-video-diffusion-img2vid-xt-1-1", torch_dtype=torch.float16, variant="fp16", use_auth_token=hf_token
34
  )
35
  pipe.to("cuda")
36
  pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)