File size: 1,609 Bytes
7c2acfb
fbc2796
7c2acfb
 
fbc2796
2ecd770
 
 
 
 
 
 
50c822a
 
 
 
2ecd770
27419d7
 
 
7c2acfb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50c822a
7c2acfb
 
90909c6
7c2acfb
 
 
90909c6
7c2acfb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# ... (previous code remains the same)

# Combine Ethos description and attributes into a prompt
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:

Brand: {attributes['brand']}
Name: {attributes['name']}
SKU: {attributes['sku']}
Features: {attributes['features']}
Case Size: {attributes['casesize']}
Movement: {attributes['movement']}
Gender: {attributes['gender']}
Water Resistance: {attributes['water_resistance']}
Power Reserve: {attributes['power_reserve']}
Dial Color: {attributes['dial_color']}
Strap Material: {attributes['strap_material']}

Additional details from Ethos:
{ethos_description}

Description:"""

# Tokenize input and generate description
inputs = tokenizer(input_text, return_tensors="pt", max_length=512, truncation=True)
outputs = model.generate(
    **inputs,
    max_length=300,  # Increased to allow for longer descriptions
    min_length=200,  # Ensure a minimum length
    num_return_sequences=1,
    temperature=0.8,  # Slightly increased for more creativity
    top_k=50,
    top_p=0.95,
    do_sample=True,
    repetition_penalty=1.2,  # Prevent repetition
    length_penalty=1.5  # Encourage longer outputs
)

# Decode generated text
description = tokenizer.decode(outputs[0], skip_special_tokens=True)

# Display the final generated description
st.write("### Final Generated Description")
st.write(description)

# ... (rest of the code remains the same)