Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,7 @@ headline_gen = pipeline("text2text-generation", model="Michau/t5-base-en-generat
|
|
9 |
ar_to_en_translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ar-en")
|
10 |
en_to_ar_translator = pipeline("translation", model="Helsinki-NLP/opus-mt-en-ar")
|
11 |
|
12 |
-
|
13 |
|
14 |
def generate_headline(selected_language, text):
|
15 |
if selected_language == "Arabic":
|
@@ -17,13 +17,13 @@ def generate_headline(selected_language, text):
|
|
17 |
result1 = headline_gen(translated_text, max_length=100, truncation=True) #Translated text will go to the model, and return the proper heading in english
|
18 |
english_headline = result1[0]['generated_text'] #The heading in english
|
19 |
arabic_headline = en_to_ar_translator(english_headline)[0]['translation_text'] #Translate the heading to Arabic
|
20 |
-
image =
|
21 |
return arabic_headline, image
|
22 |
|
23 |
elif selected_language == "English":
|
24 |
result1 = headline_gen(text, max_length=100, truncation=True)
|
25 |
english_headline = result1[0]['generated_text']
|
26 |
-
image =
|
27 |
return english_headline, image
|
28 |
|
29 |
ex = [
|
|
|
9 |
ar_to_en_translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ar-en")
|
10 |
en_to_ar_translator = pipeline("translation", model="Helsinki-NLP/opus-mt-en-ar")
|
11 |
|
12 |
+
pipe_image = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")
|
13 |
|
14 |
def generate_headline(selected_language, text):
|
15 |
if selected_language == "Arabic":
|
|
|
17 |
result1 = headline_gen(translated_text, max_length=100, truncation=True) #Translated text will go to the model, and return the proper heading in english
|
18 |
english_headline = result1[0]['generated_text'] #The heading in english
|
19 |
arabic_headline = en_to_ar_translator(english_headline)[0]['translation_text'] #Translate the heading to Arabic
|
20 |
+
image = pipe_image(english_headline).images[0]
|
21 |
return arabic_headline, image
|
22 |
|
23 |
elif selected_language == "English":
|
24 |
result1 = headline_gen(text, max_length=100, truncation=True)
|
25 |
english_headline = result1[0]['generated_text']
|
26 |
+
image = pipe_image(english_headline).images[0]
|
27 |
return english_headline, image
|
28 |
|
29 |
ex = [
|