dan-vdb commited on
Commit
7d3acfe
·
1 Parent(s): 2559255

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +39 -0
  2. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import numpy as np
4
+
5
+ import torch
6
+ from transformers import pipeline
7
+ from transformers import AutoModelForCausalLM, AutoTokenizer
8
+
9
+
10
+ st.title('Marcel Proust')
11
+ st.subheader("Commencez la phrase, l'algorithme la termine.")
12
+ st.write("Note : la génération du texte prend ~ 5 minutes")
13
+
14
+
15
+
16
+
17
+ with st.form("my_form"):
18
+
19
+ text = st.text_input("Début de la phrase :", 'Je me souvenais de ce jour où Jean-Michel')
20
+
21
+ # Every form must have a submit button.
22
+ submitted = st.form_submit_button("Générer la suite")
23
+
24
+ # Load the model ---
25
+ model_checkpoint = "bigscience/bloom-560m"
26
+ tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
27
+ model = AutoModelForCausalLM.from_pretrained("dan-vdb/ProustAI")
28
+ device = torch.device("cpu")
29
+
30
+ # device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
31
+
32
+ pipe = pipeline(
33
+ "text-generation", model=model, tokenizer=tokenizer, device=device
34
+ )
35
+ # ---
36
+
37
+
38
+ if submitted:
39
+ st.write(pipe(text, num_return_sequences=1, max_length=100)[0]["generated_text"])
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ numpy==1.24.0
2
+ pandas==1.5.2
3
+ streamlit==1.16.0
4
+ torch==1.12.1
5
+ transformers==4.24.0