Spaces:
Sleeping
Sleeping
pipeline instead of local
Browse files
app.py
CHANGED
|
@@ -2,8 +2,8 @@ import streamlit as st
|
|
| 2 |
import spotipy
|
| 3 |
from streamlit_oauth import OAuth2Component
|
| 4 |
from diffusers import StableDiffusionPipeline
|
| 5 |
-
from transformers import
|
| 6 |
-
|
| 7 |
|
| 8 |
# AUTHORIZE_URL = 'https://accounts.spotify.com/authorize'
|
| 9 |
# TOKEN_URL = 'https://accounts.spotify.com/api/token'
|
|
@@ -49,21 +49,27 @@ from transformers import AutoTokenizer, AutoModelForCausalLM
|
|
| 49 |
# st.write('Prompt: ' + prompt)
|
| 50 |
|
| 51 |
prompt = "Generate 6 adjectives that describe the color, physical texture, taste, smell, vibe, and specific genre of the sum of the following songs: Rich Folks Hoax by Rodríguez, Gommorah (A Nursery Rhyme) by Rodríguez, Like Janis by Rodríguez, I Wonder by Rodríguez, Inner City Blues by Rodríguez, Forget It by Rodríguez, Hate Street Dialogue by Rodríguez, This Is Not a Song, It's an Outburst: Or, the Establishment Blues by Rodríguez, Crucify Your Mind by Rodríguez, Only Good For Conversation by Rodríguez, Sugar Man by Rodríguez, Juliette by Jackson C. Frank, Saturday Sun by Nick Drake, Fruit Tree by Nick Drake, Man In A Shed by Nick Drake, The Thoughts Of Mary Jane by Nick Drake, ' Cello Song by Nick Drake, Day Is Done by Nick Drake, Way To Blue by Nick Drake, Three Hours by Nick Drake, River Man by Nick Drake, Time Has Told Me by Nick Drake, Sunday by Nick Drake, Northern Sky by Nick Drake, Poor Boy by Nick Drake. Return only the six adjectives in this form: [\"color\", \"physical texture\", \"taste\", \"smell\", \"vibe\", \"specific genre\"]. There should only be one array printed with six adjectives that describe all of the above tracks put together. Return ONLY the array, nothing else."
|
|
|
|
| 52 |
|
| 53 |
-
tokenizer = AutoTokenizer.
|
| 54 |
-
|
|
|
|
| 55 |
|
| 56 |
-
|
| 57 |
|
| 58 |
-
|
| 59 |
-
st.write(tokenizer.decode(outputs[0]))
|
| 60 |
|
| 61 |
-
|
| 62 |
-
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
| 63 |
-
pipe = pipe.to("cuda")
|
| 64 |
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
-
image.save("generated.png")
|
| 68 |
|
| 69 |
-
st.image("generated.png", caption=f"\"{prompt}\"", use_column_width=True)
|
|
|
|
| 2 |
import spotipy
|
| 3 |
from streamlit_oauth import OAuth2Component
|
| 4 |
from diffusers import StableDiffusionPipeline
|
| 5 |
+
from transformers import pipeline
|
| 6 |
+
import torch
|
| 7 |
|
| 8 |
# AUTHORIZE_URL = 'https://accounts.spotify.com/authorize'
|
| 9 |
# TOKEN_URL = 'https://accounts.spotify.com/api/token'
|
|
|
|
| 49 |
# st.write('Prompt: ' + prompt)
|
| 50 |
|
| 51 |
prompt = "Generate 6 adjectives that describe the color, physical texture, taste, smell, vibe, and specific genre of the sum of the following songs: Rich Folks Hoax by Rodríguez, Gommorah (A Nursery Rhyme) by Rodríguez, Like Janis by Rodríguez, I Wonder by Rodríguez, Inner City Blues by Rodríguez, Forget It by Rodríguez, Hate Street Dialogue by Rodríguez, This Is Not a Song, It's an Outburst: Or, the Establishment Blues by Rodríguez, Crucify Your Mind by Rodríguez, Only Good For Conversation by Rodríguez, Sugar Man by Rodríguez, Juliette by Jackson C. Frank, Saturday Sun by Nick Drake, Fruit Tree by Nick Drake, Man In A Shed by Nick Drake, The Thoughts Of Mary Jane by Nick Drake, ' Cello Song by Nick Drake, Day Is Done by Nick Drake, Way To Blue by Nick Drake, Three Hours by Nick Drake, River Man by Nick Drake, Time Has Told Me by Nick Drake, Sunday by Nick Drake, Northern Sky by Nick Drake, Poor Boy by Nick Drake. Return only the six adjectives in this form: [\"color\", \"physical texture\", \"taste\", \"smell\", \"vibe\", \"specific genre\"]. There should only be one array printed with six adjectives that describe all of the above tracks put together. Return ONLY the array, nothing else."
|
| 52 |
+
st.write('Prompt: ' + prompt)
|
| 53 |
|
| 54 |
+
# tokenizer = AutoTokenizer.from_pre
|
| 55 |
+
# trained("google/gemma-7b-it", token=st.secrets["HF_ACCESS_TOKEN"])
|
| 56 |
+
# model = AutoModelForCausalLM.from_pretrained("google/gemma-7b-it", token=st.secrets["HF_ACCESS_TOKEN"])
|
| 57 |
|
| 58 |
+
pipe = pipeline("text-generation", model="google/gemma-7b-it")
|
| 59 |
|
| 60 |
+
pipe(prompt)
|
|
|
|
| 61 |
|
| 62 |
+
# input_ids = tokenizer(prompt, return_tensors="pt")
|
|
|
|
|
|
|
| 63 |
|
| 64 |
+
# outputs = model.generate(**input_ids)
|
| 65 |
+
# st.write(tokenizer.decode(outputs[0]))
|
| 66 |
+
|
| 67 |
+
# model_id = "runwayml/stable-diffusion-v1-5"
|
| 68 |
+
# pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
| 69 |
+
# pipe = pipe.to("cuda")
|
| 70 |
+
|
| 71 |
+
# image = pipe(prompt).images[0]
|
| 72 |
|
| 73 |
+
# image.save("generated.png")
|
| 74 |
|
| 75 |
+
# st.image("generated.png", caption=f"\"{prompt}\"", use_column_width=True)
|