Spaces:
Sleeping
Sleeping
MilanCalegari
commited on
Commit
·
3b38e07
1
Parent(s):
5344f5d
feat: add image rotation
Browse files
app.py
CHANGED
@@ -1,11 +1,13 @@
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import yaml
|
3 |
-
from
|
4 |
-
import os
|
5 |
|
6 |
from modules.llm.card_interpreter import CardInterpreter
|
7 |
from modules.tarot.card import TarotDeck
|
8 |
from modules.utils.commom import CardReadingMethod, label4method
|
|
|
9 |
|
10 |
base_dir = os.path.dirname(os.path.abspath(__file__))
|
11 |
data_dir = os.path.join(base_dir, "data")
|
@@ -26,7 +28,8 @@ st.title("🔮 Tarot Reading")
|
|
26 |
# Secret configurations
|
27 |
with st.sidebar:
|
28 |
if 'expander_state' not in st.session_state:
|
29 |
-
st.session_state
|
|
|
30 |
with st.expander("⚙️ Settings", expanded=False):
|
31 |
reversed_prob = st.slider(
|
32 |
"Probability of reversed cards",
|
@@ -96,10 +99,17 @@ if st.button(draw_button):
|
|
96 |
for idx, (card, col) in enumerate(zip(cards, cols)):
|
97 |
with col:
|
98 |
with st.spinner(spinner_texts["reveal"]):
|
99 |
-
|
100 |
-
card.image_pth
|
101 |
-
|
102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
# Generate and display interpretation
|
105 |
with st.spinner(spinner_texts["consult"]):
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
import streamlit as st
|
4 |
import yaml
|
5 |
+
from PIL import Image
|
|
|
6 |
|
7 |
from modules.llm.card_interpreter import CardInterpreter
|
8 |
from modules.tarot.card import TarotDeck
|
9 |
from modules.utils.commom import CardReadingMethod, label4method
|
10 |
+
from scripts.get_cards import get_cards
|
11 |
|
12 |
base_dir = os.path.dirname(os.path.abspath(__file__))
|
13 |
data_dir = os.path.join(base_dir, "data")
|
|
|
28 |
# Secret configurations
|
29 |
with st.sidebar:
|
30 |
if 'expander_state' not in st.session_state:
|
31 |
+
st.session_state['is_expanded'] = False
|
32 |
+
|
33 |
with st.expander("⚙️ Settings", expanded=False):
|
34 |
reversed_prob = st.slider(
|
35 |
"Probability of reversed cards",
|
|
|
99 |
for idx, (card, col) in enumerate(zip(cards, cols)):
|
100 |
with col:
|
101 |
with st.spinner(spinner_texts["reveal"]):
|
102 |
+
if card.reversed:
|
103 |
+
img = Image.open(card.image_pth).rotate(180)
|
104 |
+
st.image(
|
105 |
+
img,
|
106 |
+
caption=f"{label4method[CardReadingMethod(method)][idx]}: {card.name} (Reversed)",
|
107 |
+
)
|
108 |
+
else:
|
109 |
+
st.image(
|
110 |
+
card.image_pth,
|
111 |
+
caption=f"{label4method[CardReadingMethod(method)][idx]}: {card.name}",
|
112 |
+
)
|
113 |
|
114 |
# Generate and display interpretation
|
115 |
with st.spinner(spinner_texts["consult"]):
|