play_with_baby_llama2 / baby_llama2.py
Ritori's picture
Upload folder using huggingface_hub
613e5d1
raw
history blame
684 Bytes
import subprocess
import gradio as gr
from translate import Translator
def generate_text():
cmd = ['./run', 'model.bin']
result = subprocess.run(cmd, stdout=subprocess.PIPE, text=True)
translator= Translator(from_lang='en', to_lang='zh-cn')
# Split the output into sentences
sentences = result.stdout.split('. ')
# Translate each sentence and join them back together
translation = '. '.join(translator.translate(sentence) for sentence in sentences)
return translation
iface = gr.Interface(
fn=generate_text,
inputs=[],
outputs="text",
submit_label="开始生成",
title="和小羊驼一起玩"
)
iface.launch()