Kvikontent commited on
Commit
50a9df3
·
1 Parent(s): 538cb39

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -14
app.py CHANGED
@@ -4,13 +4,10 @@ import requests
4
  from PIL import Image
5
  from io import BytesIO
6
 
7
- # Set the replicate API token
8
- import os
9
- os.environ["REPLICATE_API_TOKEN"] = "r8_JSR8xlRoCk6cmq3qEOOThVTn3dAgdPq1bWXdj"
10
-
11
- def run_replicate_model(input_params):
12
  output = replicate.run(
13
  "stability-ai/stable-video-diffusion:3f0457e4619daac51203dedb472816fd4af51f3149fa7a9e0b5ffcf1b8172438",
 
14
  input=input_params
15
  )
16
  return output
@@ -18,6 +15,9 @@ def run_replicate_model(input_params):
18
  st.title("Stable Video Diffusion")
19
  st.write("Fill in the input parameters and click on the button to run the Stable Video Diffusion model.")
20
 
 
 
 
21
  # Allow users to upload an image file or provide a URL
22
  uploaded_file = st.file_uploader("Upload Image File", type=["jpg", "png", "jpeg"])
23
  input_image = None
@@ -46,12 +46,15 @@ input_params = {
46
  }
47
 
48
  if st.button("Run Model"):
49
- output_result = run_replicate_model(input_params)
50
- st.write("Output Video:")
51
-
52
- try:
53
- response = requests.get(output_result)
54
- video_bytes = BytesIO(response.content)
55
- st.video(video_bytes)
56
- except Exception as e:
57
- st.write("Unable to display the video.")
 
 
 
 
4
  from PIL import Image
5
  from io import BytesIO
6
 
7
+ def run_replicate_model(api_key, input_params):
 
 
 
 
8
  output = replicate.run(
9
  "stability-ai/stable-video-diffusion:3f0457e4619daac51203dedb472816fd4af51f3149fa7a9e0b5ffcf1b8172438",
10
+ api_key=api_key,
11
  input=input_params
12
  )
13
  return output
 
15
  st.title("Stable Video Diffusion")
16
  st.write("Fill in the input parameters and click on the button to run the Stable Video Diffusion model.")
17
 
18
+ # Input field for Replicate API token
19
+ api_key = st.text_input("Replicate API Token")
20
+
21
  # Allow users to upload an image file or provide a URL
22
  uploaded_file = st.file_uploader("Upload Image File", type=["jpg", "png", "jpeg"])
23
  input_image = None
 
46
  }
47
 
48
  if st.button("Run Model"):
49
+ if api_key:
50
+ output_result = run_replicate_model(api_key, input_params)
51
+ st.write("Output Video:")
52
+
53
+ try:
54
+ response = requests.get(output_result)
55
+ video_bytes = BytesIO(response.content)
56
+ st.video(video_bytes)
57
+ except Exception as e:
58
+ st.write("Unable to display the video.")
59
+ else:
60
+ st.write("Please provide your Replicate API Token.")