Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -10,17 +10,14 @@ tokenizer = BartTokenizer.from_pretrained(model_name)
|
|
10 |
model = BartForConditionalGeneration.from_pretrained(model_name)
|
11 |
|
12 |
def generate_tweet(label):
|
13 |
-
#
|
14 |
-
prompt = f"
|
15 |
-
|
16 |
inputs = tokenizer.encode(prompt, return_tensors="pt")
|
17 |
outputs = model.generate(inputs, max_length=280, num_return_sequences=1, no_repeat_ngram_size=2)
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
# Process the generated tweet to remove unwanted patterns (additional processing can be added if needed)
|
22 |
-
tweet = tweet_raw.replace("Write a short post about", "") # Ensure this phrase is not included
|
23 |
-
|
24 |
return tweet
|
25 |
|
26 |
def predict(image):
|
|
|
10 |
model = BartForConditionalGeneration.from_pretrained(model_name)
|
11 |
|
12 |
def generate_tweet(label):
|
13 |
+
# Craft a prompt that naturally encourages engaging and relevant tweet content
|
14 |
+
prompt = f"Imagine you're at an event celebrating {label}. What's something exciting you'd share about it on social media?"
|
15 |
+
|
16 |
inputs = tokenizer.encode(prompt, return_tensors="pt")
|
17 |
outputs = model.generate(inputs, max_length=280, num_return_sequences=1, no_repeat_ngram_size=2)
|
18 |
+
|
19 |
+
tweet = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
20 |
+
|
|
|
|
|
|
|
21 |
return tweet
|
22 |
|
23 |
def predict(image):
|