Spaces:
Runtime error
Runtime error
gaspar-avit
commited on
Commit
•
3eaf0d9
1
Parent(s):
5c3c7cb
Update app.py
Browse files
app.py
CHANGED
@@ -175,16 +175,16 @@ def query_summary(text):
|
|
175 |
return text
|
176 |
|
177 |
|
178 |
-
def query_generate(text, genres, year):
|
179 |
"""
|
180 |
Get image from HuggingFace Inference API
|
181 |
-param text: text to generate image
|
182 |
-return: generated image
|
183 |
"""
|
184 |
-
|
185 |
-
API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-2-1"
|
186 |
headers = {"Authorization": f"Bearer {st.secrets['hf_token']}"}
|
187 |
-
text = 'A movie
|
188 |
'. Ignore ' + ''.join(random.choices(string.ascii_letters, k=10))
|
189 |
payload = {"inputs": f"{text}", "options": {"use_cache": "false"},}
|
190 |
|
@@ -215,6 +215,7 @@ def generate_poster(movie_data):
|
|
215 |
genres_string = ', '.join(genres)
|
216 |
|
217 |
year = movie_data['year'].values[0]
|
|
|
218 |
|
219 |
|
220 |
# Get summarization of movie synopsis
|
@@ -237,7 +238,7 @@ def generate_poster(movie_data):
|
|
237 |
|
238 |
# Get image based on synopsis
|
239 |
with st.spinner("Generating poster..."):
|
240 |
-
response_content = query_generate(synopsis_sum, genres_string, year)
|
241 |
|
242 |
# Show image
|
243 |
try:
|
|
|
175 |
return text
|
176 |
|
177 |
|
178 |
+
def query_generate(text, title, genres, year):
|
179 |
"""
|
180 |
Get image from HuggingFace Inference API
|
181 |
-param text: text to generate image
|
182 |
-return: generated image
|
183 |
"""
|
184 |
+
API_URL = "https://api-inference.huggingface.co/models/runwayml/stable-diffusion-v1-5"
|
185 |
+
#API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-2-1"
|
186 |
headers = {"Authorization": f"Bearer {st.secrets['hf_token']}"}
|
187 |
+
text = 'A Poster for the movie ' + title.split('(')[0] + 'in portrait mode based on the following synopsis: \"' + text + '\". Style: ' + genres + '. Year ' + year + \
|
188 |
'. Ignore ' + ''.join(random.choices(string.ascii_letters, k=10))
|
189 |
payload = {"inputs": f"{text}", "options": {"use_cache": "false"},}
|
190 |
|
|
|
215 |
genres_string = ', '.join(genres)
|
216 |
|
217 |
year = movie_data['year'].values[0]
|
218 |
+
title = movie_data['title'].values[0]
|
219 |
|
220 |
|
221 |
# Get summarization of movie synopsis
|
|
|
238 |
|
239 |
# Get image based on synopsis
|
240 |
with st.spinner("Generating poster..."):
|
241 |
+
response_content = query_generate(synopsis_sum, title, genres_string, year)
|
242 |
|
243 |
# Show image
|
244 |
try:
|