Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- Dockerfile +8 -0
- app.py +5 -5
Dockerfile
CHANGED
|
@@ -22,6 +22,14 @@ WORKDIR $HOME/app
|
|
| 22 |
|
| 23 |
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
| 24 |
COPY --chown=user . $HOME/app
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
# Start the FastAPI app on port 7860, the default port expected by Spaces
|
| 27 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
|
|
|
|
| 22 |
|
| 23 |
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
| 24 |
COPY --chown=user . $HOME/app
|
| 25 |
+
|
| 26 |
+
# Copy additional directories from your local machine into the container
|
| 27 |
+
COPY --chown=user ./aspect_extraction_model $HOME/app/aspect_extraction_model
|
| 28 |
+
COPY --chown=user ./aspect_extraction_tokenizer $HOME/app/aspect_extraction_tokenizer
|
| 29 |
|
| 30 |
+
COPY --chown=user ./aspect_sentiment_model $HOME/app/aspect_sentiment_model
|
| 31 |
+
COPY --chown=user ./aspect_sentiment_tokenizer $HOME/app/aspect_sentiment_tokenizer
|
| 32 |
+
|
| 33 |
+
|
| 34 |
# Start the FastAPI app on port 7860, the default port expected by Spaces
|
| 35 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
|
app.py
CHANGED
|
@@ -114,11 +114,11 @@ class AspectSentimentPipeline(Pipeline):
|
|
| 114 |
|
| 115 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 116 |
|
| 117 |
-
aspect_extraction_model = BertForTokenClassification.from_pretrained("
|
| 118 |
-
aspect_extraction_tokenizer = BertTokenizerFast.from_pretrained("
|
| 119 |
|
| 120 |
-
aspect_sentiment_model = BertForSequenceClassification.from_pretrained("
|
| 121 |
-
aspect_sentiment_tokenizer = BertTokenizer.from_pretrained("
|
| 122 |
|
| 123 |
pipeline = AspectSentimentPipeline(
|
| 124 |
aspect_extraction_model=aspect_extraction_model,
|
|
@@ -144,4 +144,4 @@ async def predict(item: Item):
|
|
| 144 |
|
| 145 |
|
| 146 |
if __name__=="__main__":
|
| 147 |
-
uvicorn.run(app, host="0.0.0.0", port=8000)
|
|
|
|
| 114 |
|
| 115 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 116 |
|
| 117 |
+
aspect_extraction_model = BertForTokenClassification.from_pretrained("./aspect_extraction_model")
|
| 118 |
+
aspect_extraction_tokenizer = BertTokenizerFast.from_pretrained("./aspect_extraction_tokenizer")
|
| 119 |
|
| 120 |
+
aspect_sentiment_model = BertForSequenceClassification.from_pretrained("./aspect_sentiment_model")
|
| 121 |
+
aspect_sentiment_tokenizer = BertTokenizer.from_pretrained("./aspect_sentiment_tokenizer")
|
| 122 |
|
| 123 |
pipeline = AspectSentimentPipeline(
|
| 124 |
aspect_extraction_model=aspect_extraction_model,
|
|
|
|
| 144 |
|
| 145 |
|
| 146 |
if __name__=="__main__":
|
| 147 |
+
uvicorn.run(app, host="0.0.0.0", port=8000)
|