dominguezdaniel commited on
Commit
f853b31
·
verified ·
1 Parent(s): a1e2394

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -9
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
- # Updated to generate a promotional tweet without mentioning emails and websites
14
- prompt = f"Write a short post about {label}"
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_raw = tokenizer.decode(outputs[0], skip_special_tokens=True)
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):