Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -5,13 +5,14 @@ model = AutoModelForSeq2SeqLM.from_pretrained("google/flan-t5-base")
|
|
| 5 |
tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-base")
|
| 6 |
|
| 7 |
def index(prompt):
|
| 8 |
-
|
|
|
|
| 9 |
outputs = model.generate(**inputs)
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
return tokenizer.batch_decode(outputs, skip_special_tokens=True)
|
| 14 |
|
|
|
|
| 15 |
|
| 16 |
inputs_image_url = [
|
| 17 |
gr.Textbox(type="text", label="Topic Name"),
|
|
@@ -32,4 +33,4 @@ interface_image_url = gr.Interface(
|
|
| 32 |
gr.TabbedInterface(
|
| 33 |
[interface_image_url],
|
| 34 |
tab_names=['Some inference']
|
| 35 |
-
).
|
|
|
|
| 5 |
tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-base")
|
| 6 |
|
| 7 |
def index(prompt):
|
| 8 |
+
# Truncate or split the input sequence to fit within the model's maximum sequence length
|
| 9 |
+
inputs = tokenizer(prompt, return_tensors="pt", max_length=512, truncation=True)
|
| 10 |
outputs = model.generate(**inputs)
|
| 11 |
|
| 12 |
+
decoded_outputs = tokenizer.batch_decode(outputs, skip_special_tokens=True)
|
| 13 |
+
print(decoded_outputs)
|
|
|
|
| 14 |
|
| 15 |
+
return decoded_outputs
|
| 16 |
|
| 17 |
inputs_image_url = [
|
| 18 |
gr.Textbox(type="text", label="Topic Name"),
|
|
|
|
| 33 |
gr.TabbedInterface(
|
| 34 |
[interface_image_url],
|
| 35 |
tab_names=['Some inference']
|
| 36 |
+
).launch()
|