Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,11 @@
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
from transformers import pipeline
|
| 4 |
-
from
|
| 5 |
|
| 6 |
# تولید موضوع به انگلیسی
|
| 7 |
text_generator = pipeline("text-generation", model="tiiuae/falcon-rw-1b")
|
| 8 |
|
| 9 |
-
# ترجمه به فارسی با googletrans
|
| 10 |
-
translator = Translator()
|
| 11 |
-
|
| 12 |
def generate_topics(field, major, keywords, audience, level):
|
| 13 |
prompt = f"""
|
| 14 |
Suggest 3 academic thesis topics based on the following information:
|
|
@@ -20,7 +17,7 @@ Level: {level}
|
|
| 20 |
"""
|
| 21 |
|
| 22 |
english_output = text_generator(prompt, max_new_tokens=256)[0]['generated_text']
|
| 23 |
-
translated_output =
|
| 24 |
|
| 25 |
final_output = translated_output.strip() + "\n\n📢 برای مشاوره و راهنمایی تخصصی با گروه مشاوره کاسپین تماس بگیرید:\n02188252497"
|
| 26 |
return final_output
|
|
@@ -38,4 +35,4 @@ iface = gr.Interface(
|
|
| 38 |
title="🎓 پیشنهادگر موضوع پایاننامه کاسپین"
|
| 39 |
)
|
| 40 |
|
| 41 |
-
iface.launch()
|
|
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
from transformers import pipeline
|
| 4 |
+
from deep_translator import GoogleTranslator
|
| 5 |
|
| 6 |
# تولید موضوع به انگلیسی
|
| 7 |
text_generator = pipeline("text-generation", model="tiiuae/falcon-rw-1b")
|
| 8 |
|
|
|
|
|
|
|
|
|
|
| 9 |
def generate_topics(field, major, keywords, audience, level):
|
| 10 |
prompt = f"""
|
| 11 |
Suggest 3 academic thesis topics based on the following information:
|
|
|
|
| 17 |
"""
|
| 18 |
|
| 19 |
english_output = text_generator(prompt, max_new_tokens=256)[0]['generated_text']
|
| 20 |
+
translated_output = GoogleTranslator(source='en', target='fa').translate(english_output)
|
| 21 |
|
| 22 |
final_output = translated_output.strip() + "\n\n📢 برای مشاوره و راهنمایی تخصصی با گروه مشاوره کاسپین تماس بگیرید:\n02188252497"
|
| 23 |
return final_output
|
|
|
|
| 35 |
title="🎓 پیشنهادگر موضوع پایاننامه کاسپین"
|
| 36 |
)
|
| 37 |
|
| 38 |
+
iface.launch()
|