Spaces:
Runtime error
Runtime error
File size: 1,034 Bytes
473c850 4cfbb07 473c850 f97bca4 d5c55f2 473c850 d5c55f2 473c850 d5c55f2 f97bca4 d5c55f2 a9ad170 473c850 d5c55f2 473c850 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | from transformers import pipeline
import gradio, requests
#DEFINE MODEL TRHU PIPELINE
pipeline = pipeline(task="translation", model="meta-llama/Meta-Llama-3-70B")
#MAKING THE FUNCION FOR API IMPLE
# def generate_translation(text_req, parameters=None,API_URL="https://api-inference.huggingface.co/models/Helsinki-NLP/opus-mt-zh-en"):
# http_header = {"Authorization": f"Bearer {{dlaitoken1}}"}
# data_input = {"inputs": text_req, "parameters": parameters}
# http_response_handler = requests.request("POST", API_URL, headers=http_header, data=data_input)
# http_response_formatted = http_response_handler.json()
# return http_response_formatted
#MAKING THE FUNCTION FOR PIPELINE IMPLE
def generate(text_req):
return pipeline(text_req)
#GRADIO INTERFACE
gradio_interface = gradio.Interface(fn=generate, inputs=[gradio.Textbox(label="WHAT DO YOU WANT TO TRANSLATE", lines=2)], outputs=[gradio.Textbox(label="TRANSLATION")], title="TRANSLATION APP")
if __name__ == "__main__":
gradio_interface.launch() |