Spaces:
Running
Running
azeus
commited on
Commit
·
768b9e4
1
Parent(s):
78e8f26
removed ephem
Browse files
app.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
from datetime import datetime
|
4 |
-
import ephem
|
5 |
import pytz
|
6 |
from transformers import pipeline
|
7 |
import math
|
@@ -27,56 +26,32 @@ except Exception as e:
|
|
27 |
st.stop()
|
28 |
|
29 |
|
30 |
-
def
|
31 |
-
"""Calculate
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
'Neptune': ephem.Neptune(),
|
57 |
-
'Pluto': ephem.Pluto()
|
58 |
-
}
|
59 |
-
|
60 |
-
for name, planet in planets.items():
|
61 |
-
planet.compute(ephem_date)
|
62 |
-
# Convert position to degrees
|
63 |
-
position_deg = math.degrees(planet.hlong)
|
64 |
-
# Normalize to 0-360 degrees
|
65 |
-
position_deg = position_deg % 360
|
66 |
-
positions[name] = position_deg
|
67 |
-
|
68 |
-
return positions
|
69 |
-
|
70 |
-
|
71 |
-
def get_zodiac_sign(longitude):
|
72 |
-
"""Convert longitude to zodiac sign."""
|
73 |
-
signs = [
|
74 |
-
"Aries", "Taurus", "Gemini", "Cancer",
|
75 |
-
"Leo", "Virgo", "Libra", "Scorpio",
|
76 |
-
"Sagittarius", "Capricorn", "Aquarius", "Pisces"
|
77 |
-
]
|
78 |
-
sign_index = int(longitude / 30)
|
79 |
-
return signs[sign_index]
|
80 |
|
81 |
|
82 |
def get_element(sign):
|
@@ -90,44 +65,38 @@ def get_element(sign):
|
|
90 |
return elements.get(sign, "Unknown")
|
91 |
|
92 |
|
93 |
-
def
|
94 |
-
"""
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
|
107 |
-
# Find dominant element
|
108 |
-
dominant_element = max(elements_count.items(), key=lambda x: x[1])[0]
|
109 |
-
prompt += f"\nDominant element: {dominant_element}\n"
|
110 |
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
angle = abs(pos1 - pos2) % 360
|
117 |
-
if abs(angle - 120) < 8: # Trine
|
118 |
-
aspects.append(f"Harmonious trine between {planet1} and {planet2}")
|
119 |
-
elif abs(angle - 90) < 8: # Square
|
120 |
-
aspects.append(f"Challenging square between {planet1} and {planet2}")
|
121 |
-
elif abs(angle - 180) < 8: # Opposition
|
122 |
-
aspects.append(f"Dynamic opposition between {planet1} and {planet2}")
|
123 |
|
124 |
-
|
125 |
-
|
|
|
|
|
|
|
|
|
126 |
|
127 |
-
|
|
|
128 |
|
129 |
try:
|
130 |
-
# Generate prediction using the model
|
131 |
prediction = generator(
|
132 |
prompt,
|
133 |
max_length=200,
|
@@ -135,9 +104,7 @@ def generate_prediction(planetary_positions):
|
|
135 |
temperature=0.7
|
136 |
)[0]['generated_text']
|
137 |
|
138 |
-
|
139 |
-
prediction = prediction.split("today's prediction: ")[-1].strip()
|
140 |
-
return prediction
|
141 |
except Exception as e:
|
142 |
return "Unable to generate prediction at this time. Please try again later."
|
143 |
|
@@ -167,30 +134,26 @@ timezone = st.selectbox(
|
|
167 |
)
|
168 |
|
169 |
if st.button("Get Prediction"):
|
170 |
-
with st.spinner("Calculating
|
171 |
try:
|
172 |
-
#
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
element
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
})
|
187 |
-
|
188 |
-
df = pd.DataFrame(planet_data)
|
189 |
-
st.table(df)
|
190 |
|
191 |
# Generate and display prediction
|
192 |
st.subheader("Your Daily Prediction")
|
193 |
-
prediction = generate_prediction(
|
194 |
st.write(prediction)
|
195 |
|
196 |
# Add disclaimer
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
from datetime import datetime
|
|
|
4 |
import pytz
|
5 |
from transformers import pipeline
|
6 |
import math
|
|
|
26 |
st.stop()
|
27 |
|
28 |
|
29 |
+
def calculate_zodiac_sign(month, day):
|
30 |
+
"""Calculate zodiac sign based on birth date."""
|
31 |
+
if (month == 3 and day >= 21) or (month == 4 and day <= 19):
|
32 |
+
return "Aries"
|
33 |
+
elif (month == 4 and day >= 20) or (month == 5 and day <= 20):
|
34 |
+
return "Taurus"
|
35 |
+
elif (month == 5 and day >= 21) or (month == 6 and day <= 20):
|
36 |
+
return "Gemini"
|
37 |
+
elif (month == 6 and day >= 21) or (month == 7 and day <= 22):
|
38 |
+
return "Cancer"
|
39 |
+
elif (month == 7 and day >= 23) or (month == 8 and day <= 22):
|
40 |
+
return "Leo"
|
41 |
+
elif (month == 8 and day >= 23) or (month == 9 and day <= 22):
|
42 |
+
return "Virgo"
|
43 |
+
elif (month == 9 and day >= 23) or (month == 10 and day <= 22):
|
44 |
+
return "Libra"
|
45 |
+
elif (month == 10 and day >= 23) or (month == 11 and day <= 21):
|
46 |
+
return "Scorpio"
|
47 |
+
elif (month == 11 and day >= 22) or (month == 12 and day <= 21):
|
48 |
+
return "Sagittarius"
|
49 |
+
elif (month == 12 and day >= 22) or (month == 1 and day <= 19):
|
50 |
+
return "Capricorn"
|
51 |
+
elif (month == 1 and day >= 20) or (month == 2 and day <= 18):
|
52 |
+
return "Aquarius"
|
53 |
+
else:
|
54 |
+
return "Pisces"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
|
57 |
def get_element(sign):
|
|
|
65 |
return elements.get(sign, "Unknown")
|
66 |
|
67 |
|
68 |
+
def calculate_nakshatra(birth_date):
|
69 |
+
"""Calculate Nakshatra based on birth date (simplified calculation)."""
|
70 |
+
nakshatras = [
|
71 |
+
"Ashwini", "Bharani", "Krittika", "Rohini", "Mrigashira", "Ardra",
|
72 |
+
"Punarvasu", "Pushya", "Ashlesha", "Magha", "Purva Phalguni",
|
73 |
+
"Uttara Phalguni", "Hasta", "Chitra", "Swati", "Vishakha", "Anuradha",
|
74 |
+
"Jyeshtha", "Mula", "Purva Ashadha", "Uttara Ashadha", "Shravana",
|
75 |
+
"Dhanishta", "Shatabhisha", "Purva Bhadrapada", "Uttara Bhadrapada", "Revati"
|
76 |
+
]
|
77 |
+
# Simplified calculation based on birth date
|
78 |
+
day_of_year = birth_date.timetuple().tm_yday
|
79 |
+
nakshatra_index = (day_of_year * 27) // 365
|
80 |
+
return nakshatras[nakshatra_index]
|
81 |
|
|
|
|
|
|
|
82 |
|
83 |
+
def generate_prediction(birth_date, birth_time, timezone):
|
84 |
+
"""Generate prediction based on astrological factors."""
|
85 |
+
zodiac_sign = calculate_zodiac_sign(birth_date.month, birth_date.day)
|
86 |
+
element = get_element(zodiac_sign)
|
87 |
+
nakshatra = calculate_nakshatra(birth_date)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
+
prompt = f"""
|
90 |
+
Astrological reading for a person born under:
|
91 |
+
- Zodiac Sign: {zodiac_sign}
|
92 |
+
- Element: {element}
|
93 |
+
- Nakshatra: {nakshatra}
|
94 |
+
- Birth Time: {birth_time.strftime('%H:%M')}
|
95 |
|
96 |
+
Based on these positions, today's prediction:
|
97 |
+
"""
|
98 |
|
99 |
try:
|
|
|
100 |
prediction = generator(
|
101 |
prompt,
|
102 |
max_length=200,
|
|
|
104 |
temperature=0.7
|
105 |
)[0]['generated_text']
|
106 |
|
107 |
+
return prediction.split("today's prediction: ")[-1].strip()
|
|
|
|
|
108 |
except Exception as e:
|
109 |
return "Unable to generate prediction at this time. Please try again later."
|
110 |
|
|
|
134 |
)
|
135 |
|
136 |
if st.button("Get Prediction"):
|
137 |
+
with st.spinner("Calculating astrological factors and generating prediction..."):
|
138 |
try:
|
139 |
+
# Display birth chart information
|
140 |
+
st.subheader("Your Astrological Profile")
|
141 |
+
zodiac_sign = calculate_zodiac_sign(birth_date.month, birth_date.day)
|
142 |
+
element = get_element(zodiac_sign)
|
143 |
+
nakshatra = calculate_nakshatra(birth_date)
|
144 |
+
|
145 |
+
profile_data = pd.DataFrame([{
|
146 |
+
"Zodiac Sign": zodiac_sign,
|
147 |
+
"Element": element,
|
148 |
+
"Nakshatra": nakshatra,
|
149 |
+
"Birth Time": birth_time.strftime("%H:%M")
|
150 |
+
}])
|
151 |
+
|
152 |
+
st.table(profile_data)
|
|
|
|
|
|
|
|
|
153 |
|
154 |
# Generate and display prediction
|
155 |
st.subheader("Your Daily Prediction")
|
156 |
+
prediction = generate_prediction(birth_date, birth_time, timezone)
|
157 |
st.write(prediction)
|
158 |
|
159 |
# Add disclaimer
|