Rooni commited on
Commit
9b2ffff
·
verified ·
1 Parent(s): 89cd4af

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -12
app.py CHANGED
@@ -12,18 +12,24 @@ client = Client("KingNish/Instant-Video")
12
 
13
  # Function
14
  def generate_image(prompt, base="Anime", motion="", step=8, progress=gr.Progress()):
15
- try:
16
- result = client.predict(
17
- prompt=prompt,
18
- base=base,
19
- motion=motion,
20
- step=step,
21
- api_name="/generate_image_1"
22
- )
23
- video_path = result["video"]
24
- return video_path
25
- except ValueError as e:
26
- raise gr.Error("Произошла ошибка. Повторите попытку позже.")
 
 
 
 
 
 
27
 
28
  # Gradio Interface
29
  with gr.Blocks(css="style.css") as demo:
 
12
 
13
  # Function
14
  def generate_image(prompt, base="Anime", motion="", step=8, progress=gr.Progress()):
15
+ API_URL = "https://api-inference.huggingface.co/models/KingNish/Instant-Video"
16
+ headers = {"Authorization": f"Bearer {os.environ.get('HF_API_TOKEN')}"} # Замените на ваш токен Hugging Face API
17
+
18
+ payload = {
19
+ "inputs": prompt,
20
+ "options": {
21
+ "base": base,
22
+ "motion": motion,
23
+ "step": step
24
+ }
25
+ }
26
+
27
+ response = requests.post(API_URL, headers=headers, json=payload)
28
+ response.raise_for_status()
29
+
30
+ video_url = response.json()[0]['video']
31
+ video_path = cached_download(video_url)
32
+ return video_path
33
 
34
  # Gradio Interface
35
  with gr.Blocks(css="style.css") as demo: