Spaces:
Runtime error
Runtime error
gaspar-avit
commited on
Commit
•
c19700b
1
Parent(s):
9ebedb6
Upload app.py
Browse files
app.py
CHANGED
@@ -189,6 +189,7 @@ def query_generate(text, genres, year):
|
|
189 |
headers = {"Authorization": f"Bearer {st.secrets['hf_token']}"}
|
190 |
text = 'A movie Poster based on the following synopsis: \"' + text + '\". Style: ' + genres + ', year ' + year + \
|
191 |
'. Ignore ' + ''.join(random.choices(string.ascii_letters, k=10))
|
|
|
192 |
payload = {"inputs": f"{text}",}
|
193 |
|
194 |
response = requests.post(API_URL, headers=headers, json=payload)
|
@@ -237,7 +238,7 @@ def generate_poster(movie_data):
|
|
237 |
|
238 |
|
239 |
# Get image based on synopsis
|
240 |
-
with st.spinner("Generating poster image..."):
|
241 |
response_content = query_generate(synopsis_sum, genres_string, year)
|
242 |
|
243 |
# Show image
|
@@ -306,15 +307,15 @@ if __name__ == "__main__":
|
|
306 |
buffer1, col1, buffer2 = st.columns([1.3, 1, 1])
|
307 |
is_clicked = col1.button(label="Generate poster!")
|
308 |
|
|
|
|
|
|
|
|
|
309 |
## Generate poster
|
310 |
if is_clicked:
|
311 |
poster = generate_poster(data[data.title_year==session.selected_movie])
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
## Clear cache between runs
|
316 |
-
#st.runtime.legacy_caching.clear_cache()
|
317 |
-
#generate_poster.clear()
|
318 |
|
319 |
|
320 |
_= """
|
|
|
189 |
headers = {"Authorization": f"Bearer {st.secrets['hf_token']}"}
|
190 |
text = 'A movie Poster based on the following synopsis: \"' + text + '\". Style: ' + genres + ', year ' + year + \
|
191 |
'. Ignore ' + ''.join(random.choices(string.ascii_letters, k=10))
|
192 |
+
st.write(text)
|
193 |
payload = {"inputs": f"{text}",}
|
194 |
|
195 |
response = requests.post(API_URL, headers=headers, json=payload)
|
|
|
238 |
|
239 |
|
240 |
# Get image based on synopsis
|
241 |
+
with st.spinner("Generating poster image... This could take a few minutes."):
|
242 |
response_content = query_generate(synopsis_sum, genres_string, year)
|
243 |
|
244 |
# Show image
|
|
|
307 |
buffer1, col1, buffer2 = st.columns([1.3, 1, 1])
|
308 |
is_clicked = col1.button(label="Generate poster!")
|
309 |
|
310 |
+
## Clear cache between runs
|
311 |
+
st.runtime.legacy_caching.clear_cache()
|
312 |
+
generate_poster.clear()
|
313 |
+
|
314 |
## Generate poster
|
315 |
if is_clicked:
|
316 |
poster = generate_poster(data[data.title_year==session.selected_movie])
|
317 |
+
generate_poster.clear()
|
318 |
+
st.runtime.legacy_caching.clear_cache()
|
|
|
|
|
|
|
|
|
319 |
|
320 |
|
321 |
_= """
|