repo_test / hello.py
Sara29's picture
add: text generation and translation
568580a
Raw
History Blame Contribute Delete
473 Bytes
from transformers import pipeline
# Specifica il modello e la revisione
model_name = "openai-community/gpt2"
# Utilizza la pipeline specificando il modello
classifier = pipeline("text-generation", model=model_name)
# Utilizza la pipeline come prima
result = classifier("Mario is Super Mario")
# print(result[0]['generated_text'])
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-en-it")
result2 = translator(result[0]['generated_text'])
print(result2)