Roboproch commited on
Commit
1095f7c
·
1 Parent(s): d9fd99e

ottimizzazione requirements e versioni per alleggerire

Browse files
Files changed (5) hide show
  1. .dockerignore +2 -1
  2. Dockerfile +1 -1
  3. app.py +1 -2
  4. requirements.txt +3 -1
  5. src/modello.py +3 -2
.dockerignore CHANGED
@@ -6,4 +6,5 @@ env
6
  .ipynb_checkpoints
7
  data/
8
  *.bin
9
- *.pt
 
 
6
  .ipynb_checkpoints
7
  data/
8
  *.bin
9
+ *.pt
10
+ .pytest_cache
Dockerfile CHANGED
@@ -1,7 +1,7 @@
1
  #dockerfile
2
 
3
  # Versione di Python
4
- FROM python:3.12.1
5
 
6
  # Set della working directory
7
  WORKDIR /app
 
1
  #dockerfile
2
 
3
  # Versione di Python
4
+ FROM python:3.12-slim
5
 
6
  # Set della working directory
7
  WORKDIR /app
app.py CHANGED
@@ -9,7 +9,7 @@ dataset = LoadDataset()
9
 
10
  X = dataset.X
11
  y = dataset.y
12
- y_pred = []
13
 
14
  valori = ['negative', 'neutral', 'positive']
15
 
@@ -29,5 +29,4 @@ demo = gr.Interface(
29
  )
30
 
31
  if __name__ == "__main__":
32
- # y_pred = model.predict(X)
33
  demo.launch()
 
9
 
10
  X = dataset.X
11
  y = dataset.y
12
+ y_pred = model.predict(X)
13
 
14
  valori = ['negative', 'neutral', 'positive']
15
 
 
29
  )
30
 
31
  if __name__ == "__main__":
 
32
  demo.launch()
requirements.txt CHANGED
@@ -1,5 +1,7 @@
 
1
  transformers
2
- torch
 
3
  pandas
4
  scikit-learn
5
  datasets
 
1
+ --extra-index-url https://download.pytorch.org/whl/cpu
2
  transformers
3
+ torch==2.2.1+cpu
4
+ torchvision==0.17.1+cpu
5
  pandas
6
  scikit-learn
7
  datasets
src/modello.py CHANGED
@@ -2,8 +2,9 @@ from transformers import pipeline
2
 
3
  class Modello :
4
 
5
- # Import del modello da Hugging Face
6
- sentiment_task = pipeline("sentiment-analysis", model="cardiffnlp/twitter-roberta-base-sentiment-latest", tokenizer="cardiffnlp/twitter-roberta-base-sentiment-latest")
 
7
 
8
  def predict(self,tweets) :
9
  # Metodo per le predizioni, prende in input una o più stringhe
 
2
 
3
  class Modello :
4
 
5
+ def __init__(self) :
6
+ # Import del modello da Hugging Face
7
+ self.sentiment_task = pipeline("sentiment-analysis", model="cardiffnlp/twitter-roberta-base-sentiment-latest", tokenizer="cardiffnlp/twitter-roberta-base-sentiment-latest")
8
 
9
  def predict(self,tweets) :
10
  # Metodo per le predizioni, prende in input una o più stringhe