shreyanshjha0709 commited on
Commit
51621c3
·
verified ·
1 Parent(s): 3da548a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -46,12 +46,17 @@ if selected_brand != "Select":
46
  watch_data = next((item for item in data if item["sku"] == selected_sku), None)
47
 
48
  if watch_data:
 
 
 
 
 
49
  # Generation parameters
50
- max_length = st.slider("Max Length", min_value=100, max_value=500, value=300) # Increase max length to allow for more text
51
  temperature = st.slider("Temperature", min_value=0.1, max_value=1.0, value=0.7, step=0.1)
52
- repetition_penalty = st.slider("Repetition Penalty", min_value=1.0, max_value=2.0, value=1.2, step=0.1) # Penalize repetitive text
53
 
54
- # Generate description based on attributes
55
  if st.button("Generate Description"):
56
  attributes = {
57
  "brand": watch_data["brand"],
@@ -61,9 +66,10 @@ if selected_brand != "Select":
61
  "casesize": watch_data.get("casesize", "Unknown Case Size"),
62
  "movement": watch_data.get("movement", "Unknown Movement"),
63
  "gender": watch_data.get("gender", "Unknown Gender"),
 
64
  }
65
 
66
- # Format input similar to training data (adjust this based on your training data format)
67
  input_text = f"""Generate a detailed description for the following watch:
68
  Brand: {attributes['brand']}
69
  Name: {attributes['name']}
@@ -72,6 +78,8 @@ Features: {attributes['features']}
72
  Case Size: {attributes['casesize']}
73
  Movement: {attributes['movement']}
74
  Gender: {attributes['gender']}
 
 
75
 
76
  Description:"""
77
 
 
46
  watch_data = next((item for item in data if item["sku"] == selected_sku), None)
47
 
48
  if watch_data:
49
+ # Display the image from the JSON
50
+ image_url = watch_data.get("image", None) # Assume the "image" key holds the image URL
51
+ if image_url:
52
+ st.image(image_url, caption=f"{watch_data['name']} Image")
53
+
54
  # Generation parameters
55
+ max_length = st.slider("Max Length", min_value=100, max_value=500, value=300)
56
  temperature = st.slider("Temperature", min_value=0.1, max_value=1.0, value=0.7, step=0.1)
57
+ repetition_penalty = st.slider("Repetition Penalty", min_value=1.0, max_value=2.0, value=1.2, step=0.1)
58
 
59
+ # Generate description based on attributes and image
60
  if st.button("Generate Description"):
61
  attributes = {
62
  "brand": watch_data["brand"],
 
66
  "casesize": watch_data.get("casesize", "Unknown Case Size"),
67
  "movement": watch_data.get("movement", "Unknown Movement"),
68
  "gender": watch_data.get("gender", "Unknown Gender"),
69
+ "color": watch_data.get("color", "Unknown Color"), # Simulated color field
70
  }
71
 
72
+ # Simulate a description that mentions the color, look, and other aspects
73
  input_text = f"""Generate a detailed description for the following watch:
74
  Brand: {attributes['brand']}
75
  Name: {attributes['name']}
 
78
  Case Size: {attributes['casesize']}
79
  Movement: {attributes['movement']}
80
  Gender: {attributes['gender']}
81
+ Color: {attributes['color']}
82
+ Look: Based on its stunning design, as seen in the image, this watch has a {attributes['color']} finish that complements its {attributes['casesize']}mm case size. It exudes elegance and sophistication, making it perfect for {attributes['gender']} audiences. The craftsmanship seen in the movement adds to its luxurious appeal.
83
 
84
  Description:"""
85