ituvtu commited on
Commit
24bab16
·
1 Parent(s): 0c383ea

Deploy: Metadata & Cleanup

Browse files
Files changed (5) hide show
  1. .dockerignore +0 -25
  2. Dockerfile +0 -15
  3. README.md +11 -0
  4. tests/__init__.py +0 -0
  5. tests/test_app.py +0 -57
.dockerignore DELETED
@@ -1,25 +0,0 @@
1
- .git
2
- .gitignore
3
- .gitattributes
4
-
5
- .vscode
6
- .idea
7
-
8
-
9
- .venv
10
- venv
11
- env
12
-
13
-
14
- Dockerfile
15
- .dockerignore
16
-
17
-
18
- README.md
19
- assets
20
-
21
-
22
- __pycache__
23
- *.pyc
24
- *.pyo
25
- *.pyd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Dockerfile DELETED
@@ -1,15 +0,0 @@
1
- FROM python:3.10-slim
2
-
3
- WORKDIR /app
4
-
5
- COPY requirements.txt .
6
-
7
- RUN pip install --no-cache-dir -r requirements.txt
8
-
9
- COPY . .
10
-
11
- EXPOSE 7860
12
-
13
- ENV GRADIO_SERVER_NAME="0.0.0.0"
14
-
15
- CMD ["python", "app.py"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README.md CHANGED
@@ -1,3 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
1
  # 📰 DistilBERT AG News Classification
2
 
3
  [![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Live%20Demo-blue)](https://huggingface.co/spaces/ituvtu/DistilBERT-multi-text)
 
1
+ ---
2
+ title: DistilBERT Multi Text
3
+ colorFrom: blue
4
+ colorTo: yellow
5
+ sdk: gradio
6
+ sdk_version: 6.0.1
7
+ app_file: app.py
8
+ pinned: false
9
+ license: mit
10
+ short_description: Multiclass text classification with fine-tuned DistilBERT
11
+ ---
12
  # 📰 DistilBERT AG News Classification
13
 
14
  [![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Live%20Demo-blue)](https://huggingface.co/spaces/ituvtu/DistilBERT-multi-text)
tests/__init__.py DELETED
File without changes
tests/test_app.py DELETED
@@ -1,57 +0,0 @@
1
- import pytest
2
- import json
3
- import os
4
- from unittest.mock import patch, MagicMock
5
-
6
-
7
- from app import load_example_headlines, classify_headline
8
-
9
-
10
- def test_load_example_headlines_valid(tmp_path):
11
- """Check whether the function reads a valid JSON file."""
12
-
13
- data = [["Headline 1"], ["Headline 2"]]
14
- file = tmp_path / "test_examples.json"
15
- file.write_text(json.dumps(data), encoding="utf-8")
16
-
17
- result = load_example_headlines(str(file))
18
- assert result == data
19
-
20
- def test_load_example_headlines_invalid():
21
- """Check whether the function returns an empty list in case of an error."""
22
- result = load_example_headlines("non_existent_file.json")
23
- assert result == []
24
-
25
-
26
-
27
- @patch('app.news_classifier')
28
- def test_classify_headline_success(mock_classifier):
29
- """
30
- Verify the successful classification.
31
- """
32
- mock_classifier.return_value = [
33
- {"label": "Sports", "score": 0.95},
34
- {"label": "World", "score": 0.05}
35
- ]
36
-
37
- text = "Team wins the match"
38
- result = classify_headline(text)
39
-
40
- assert result["Sports"] == 0.95
41
- assert result["World"] == 0.05
42
- mock_classifier.assert_called_with(text, top_k=None)
43
-
44
- @patch('app.news_classifier')
45
- def test_classify_headline_empty_input(mock_classifier):
46
- """Checking the handling of empty input."""
47
- result = classify_headline("")
48
- assert "Please enter valid text" in result
49
- assert result["Please enter valid text"] == 0.0
50
-
51
- mock_classifier.assert_not_called()
52
-
53
- def test_classify_headline_model_none():
54
- """Check the case when the model did not load (news_classifier is None)."""
55
- with patch('app.news_classifier', None):
56
- result = classify_headline("Some text")
57
- assert "Model failed to initialize" in result