dominguezdaniel commited on
Commit
1494c0e
·
verified ·
1 Parent(s): 88ea942

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -10,11 +10,17 @@ tokenizer = BartTokenizer.from_pretrained(model_name)
10
  model = BartForConditionalGeneration.from_pretrained(model_name)
11
 
12
  def generate_tweet(label):
13
- # Generate a promotional tweet using a GPT-like model
14
  prompt = f"Write a tweet about {label}"
 
15
  inputs = tokenizer.encode(prompt, return_tensors="pt")
16
  outputs = model.generate(inputs, max_length=280, num_return_sequences=1, no_repeat_ngram_size=2)
17
- tweet = tokenizer.decode(outputs[0], skip_special_tokens=True)
 
 
 
 
 
18
  return tweet
19
 
20
  def predict(image):
 
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 tweet 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 tweet about", "") # Ensure this phrase is not included
23
+
24
  return tweet
25
 
26
  def predict(image):