Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,8 +3,6 @@ import os
|
|
3 |
import requests
|
4 |
import io
|
5 |
from PIL import Image
|
6 |
-
from IPython.display import Audio, display
|
7 |
-
from freeGPT import Client
|
8 |
|
9 |
api_token = os.environ.get("API_TOKEN")
|
10 |
API_URL = "https://api-inference.huggingface.co/models/facebook/musicgen-small"
|
@@ -16,12 +14,15 @@ st.write("Music generator using Facebook MusicGen, ChatGPT3 and Blip image capti
|
|
16 |
img_prompt = st.file_uploader("Upload Image", type=["jpeg", "jpg", "png"])
|
17 |
subm_btn = st.button("✨ Generate")
|
18 |
|
19 |
-
if subm_btn:
|
20 |
-
def query(
|
21 |
-
|
22 |
-
data = f.read()
|
23 |
-
response = requests.post(API_URL, headers=headers, data=data)
|
24 |
return response.json()
|
25 |
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
3 |
import requests
|
4 |
import io
|
5 |
from PIL import Image
|
|
|
|
|
6 |
|
7 |
api_token = os.environ.get("API_TOKEN")
|
8 |
API_URL = "https://api-inference.huggingface.co/models/facebook/musicgen-small"
|
|
|
14 |
img_prompt = st.file_uploader("Upload Image", type=["jpeg", "jpg", "png"])
|
15 |
subm_btn = st.button("✨ Generate")
|
16 |
|
17 |
+
if subm_btn and img_prompt is not None:
|
18 |
+
def query(image_bytes):
|
19 |
+
response = requests.post(API_URL_IMG, headers=headers, data=image_bytes)
|
|
|
|
|
20 |
return response.json()
|
21 |
|
22 |
+
image = Image.open(img_prompt)
|
23 |
+
image_bytes = io.BytesIO()
|
24 |
+
image.save(image_bytes, format=image.format)
|
25 |
+
image_bytes = image_bytes.getvalue()
|
26 |
+
|
27 |
+
output = query(image_bytes)
|
28 |
+
st.info(f"Generated Prompt for input image: {output}")
|