Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -94,11 +94,8 @@ if selected_brand != "Select":
|
|
94 |
"strap_material": watch_data.get("strap_material", "Unknown Strap Material")
|
95 |
}
|
96 |
|
97 |
-
#
|
98 |
-
|
99 |
-
# Combine Ethos description and attributes into a prompt
|
100 |
input_text = f"""Generate a detailed, luxurious 150-word description for the following watch, focusing on its craftsmanship, innovation, and design. Use a style similar to high-end watch editorials, highlighting the watch's unique features and its appeal to connoisseurs:
|
101 |
-
|
102 |
Brand: {attributes['brand']}
|
103 |
Name: {attributes['name']}
|
104 |
SKU: {attributes['sku']}
|
@@ -116,7 +113,7 @@ Additional details from Ethos:
|
|
116 |
|
117 |
Description:"""
|
118 |
|
119 |
-
# Tokenize input and generate description
|
120 |
inputs = tokenizer(input_text, return_tensors="pt", max_length=512, truncation=True)
|
121 |
outputs = model.generate(
|
122 |
**inputs,
|
@@ -131,11 +128,41 @@ outputs = model.generate(
|
|
131 |
length_penalty=1.5 # Encourage longer outputs
|
132 |
)
|
133 |
|
134 |
-
# Decode generated text
|
135 |
description = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
136 |
|
137 |
# Display the final generated description
|
138 |
st.write("### Final Generated Description")
|
139 |
st.write(description)
|
140 |
|
141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
"strap_material": watch_data.get("strap_material", "Unknown Strap Material")
|
95 |
}
|
96 |
|
97 |
+
# Combine Ethos description and attributes into a prompt
|
|
|
|
|
98 |
input_text = f"""Generate a detailed, luxurious 150-word description for the following watch, focusing on its craftsmanship, innovation, and design. Use a style similar to high-end watch editorials, highlighting the watch's unique features and its appeal to connoisseurs:
|
|
|
99 |
Brand: {attributes['brand']}
|
100 |
Name: {attributes['name']}
|
101 |
SKU: {attributes['sku']}
|
|
|
113 |
|
114 |
Description:"""
|
115 |
|
116 |
+
# Tokenize input and generate description
|
117 |
inputs = tokenizer(input_text, return_tensors="pt", max_length=512, truncation=True)
|
118 |
outputs = model.generate(
|
119 |
**inputs,
|
|
|
128 |
length_penalty=1.5 # Encourage longer outputs
|
129 |
)
|
130 |
|
131 |
+
# Decode generated text
|
132 |
description = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
133 |
|
134 |
# Display the final generated description
|
135 |
st.write("### Final Generated Description")
|
136 |
st.write(description)
|
137 |
|
138 |
+
else:
|
139 |
+
st.warning("Please select a brand.")
|
140 |
+
|
141 |
+
# Sidebar information
|
142 |
+
st.sidebar.title("About")
|
143 |
+
st.sidebar.info(
|
144 |
+
"This app uses a fine-tuned AI model to generate descriptions for watches. "
|
145 |
+
"Select a brand and a watch to get started. The model will generate a unique "
|
146 |
+
"description based on the watch's attributes and additional details from the Ethos website."
|
147 |
+
)
|
148 |
+
|
149 |
+
# Footer
|
150 |
+
st.markdown(
|
151 |
+
"""
|
152 |
+
<style>
|
153 |
+
.footer {
|
154 |
+
position: fixed;
|
155 |
+
left: 0;
|
156 |
+
bottom: 0;
|
157 |
+
width: 100%;
|
158 |
+
background-color: #f1f1f1;
|
159 |
+
color: black;
|
160 |
+
text-align: center;
|
161 |
+
}
|
162 |
+
</style>
|
163 |
+
<div class="footer">
|
164 |
+
<p>Developed with ❤️ by Shreyansh Jha</p>
|
165 |
+
</div>
|
166 |
+
""",
|
167 |
+
unsafe_allow_html=True
|
168 |
+
)
|