create language function
Browse files- app.py +6 -12
- language.py +8 -1
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
from image import *
|
|
|
2 |
import streamlit as st
|
3 |
import torch
|
4 |
import os
|
@@ -12,16 +13,9 @@ text = st.text_input('Posez votre question (en anglais)')
|
|
12 |
url = st.text_input('mettez le liens de votre image')
|
13 |
|
14 |
if st.button('générer'):
|
15 |
-
|
16 |
-
|
17 |
-
st.write('Part 2')
|
18 |
-
|
19 |
-
|
20 |
-
print('#### TEST 2####')
|
21 |
-
|
22 |
-
from transformers import pipeline
|
23 |
-
|
24 |
-
model_checkpoint = "Helsinki-NLP/opus-mt-en-fr"
|
25 |
-
translator = pipeline("translation", model=model_checkpoint)
|
26 |
-
print(translator("How are you?"))
|
27 |
|
|
|
|
1 |
from image import *
|
2 |
+
from language import *
|
3 |
import streamlit as st
|
4 |
import torch
|
5 |
import os
|
|
|
13 |
url = st.text_input('mettez le liens de votre image')
|
14 |
|
15 |
if st.button('générer'):
|
16 |
+
responseBase = image(url, text)
|
17 |
+
st.write('response is :', responseBase)
|
18 |
+
st.write('Part 2')
|
19 |
+
st.write(longText(responseBase))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
+
print('#### TEST 2####')
|
language.py
CHANGED
@@ -13,4 +13,11 @@ model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-large")
|
|
13 |
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
|
14 |
|
15 |
outputs = model.generate(input_ids)
|
16 |
-
print(tokenizer.decode(outputs[0]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
|
14 |
|
15 |
outputs = model.generate(input_ids)
|
16 |
+
print(tokenizer.decode(outputs[0]))
|
17 |
+
|
18 |
+
def longText(input_text):
|
19 |
+
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large")
|
20 |
+
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-large")
|
21 |
+
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
|
22 |
+
outputs = model.generate(input_ids)
|
23 |
+
return tokenizer.decode(outputs[0])
|