Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from transformers import T5Tokenizer, T5ForConditionalGeneration, AutoTokenizer, AutoModelForSeq2SeqLM, pipeline, logging
|
| 3 |
import torch
|
| 4 |
import os
|
| 5 |
import httpx
|
|
@@ -136,7 +136,9 @@ if submit_button:
|
|
| 136 |
except Exception as error:
|
| 137 |
translated_text = error
|
| 138 |
if model_name == "winninghealth/WiNGPT-Babel-2":
|
| 139 |
-
|
|
|
|
|
|
|
| 140 |
translation = pipe(input_text)
|
| 141 |
translated_text = translation[0]['translation_text']
|
| 142 |
# Display the translated text
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from transformers import T5Tokenizer, T5ForConditionalGeneration, AutoTokenizer, AutoModelForSeq2SeqLM, pipeline, logging, AutoModelForCausalLM
|
| 3 |
import torch
|
| 4 |
import os
|
| 5 |
import httpx
|
|
|
|
| 136 |
except Exception as error:
|
| 137 |
translated_text = error
|
| 138 |
if model_name == "winninghealth/WiNGPT-Babel-2":
|
| 139 |
+
tokenizer = AutoTokenizer.from_pretrained("winninghealth/WiNGPT-Babel-2")
|
| 140 |
+
model = AutoModelForCausalLM.from_pretrained("winninghealth/WiNGPT-Babel-2")
|
| 141 |
+
pipe = pipeline("translation", model=model, tokenizer=tokenizer)
|
| 142 |
translation = pipe(input_text)
|
| 143 |
translated_text = translation[0]['translation_text']
|
| 144 |
# Display the translated text
|