Spaces:
Sleeping
Sleeping
Commit
·
d9e931a
1
Parent(s):
1477aed
Initial commit
Browse files- app.py +46 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import io
|
2 |
+
import os
|
3 |
+
from tempfile import NamedTemporaryFile
|
4 |
+
|
5 |
+
import replicate
|
6 |
+
import streamlit as st
|
7 |
+
from PIL import Image
|
8 |
+
from dotenv import load_dotenv
|
9 |
+
|
10 |
+
load_dotenv()
|
11 |
+
|
12 |
+
os.environ["REPLICATE_API_TOKEN"] = os.getenv("REPLICATE_API_TOKEN")
|
13 |
+
MODEL = "daanelson/minigpt-4:b96a2f33cc8e4b0aa23eacfce731b9c41a7d9466d9ed4e167375587b54db9423"
|
14 |
+
|
15 |
+
|
16 |
+
st.title("Dressing Advisor")
|
17 |
+
|
18 |
+
uploaded_file = st.file_uploader("Choose a file")
|
19 |
+
if uploaded_file is not None:
|
20 |
+
# To read file as bytes:
|
21 |
+
image_data = uploaded_file.getvalue()
|
22 |
+
image = Image.open(io.BytesIO(image_data))
|
23 |
+
|
24 |
+
with NamedTemporaryFile(suffix=".jpg") as temp_file:
|
25 |
+
image.save(temp_file.name)
|
26 |
+
|
27 |
+
output = replicate.run(
|
28 |
+
MODEL,
|
29 |
+
input={
|
30 |
+
"image": open(temp_file.name, "rb"),
|
31 |
+
"temperature": 1.3,
|
32 |
+
"prompt": "Write something about how I am dressed. Write advices on how I can improve my dressing. "
|
33 |
+
"If my dressing is good, compliment me instead."
|
34 |
+
}
|
35 |
+
)
|
36 |
+
|
37 |
+
st.divider()
|
38 |
+
|
39 |
+
col1, col2 = st.columns(2)
|
40 |
+
|
41 |
+
with col1:
|
42 |
+
st.image(image)
|
43 |
+
|
44 |
+
with col2:
|
45 |
+
with st.container():
|
46 |
+
st.write(output)
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
Pillow
|
3 |
+
replicate
|