khaled5321 Khaled27 commited on
Commit
59c8923
0 Parent(s):

Duplicate from Khaled27/Naptah

Browse files

Co-authored-by: Khaled Mohamed <Khaled27@users.noreply.huggingface.co>

Files changed (6) hide show
  1. .gitattributes +34 -0
  2. README.md +14 -0
  3. app.py +50 -0
  4. myModel/config.json +57 -0
  5. myModel/pytorch_model.bin +3 -0
  6. requirements.txt +49 -0
.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Naptah
3
+ emoji: 🏆
4
+ colorFrom: yellow
5
+ colorTo: purple
6
+ sdk: streamlit
7
+ sdk_version: 1.19.0
8
+ app_file: app.py
9
+ pinned: false
10
+ license: other
11
+ duplicated_from: Khaled27/Naptah
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, request
2
+ from transformers import AutoModelForImageClassification
3
+ from transformers import AutoImageProcessor
4
+ from PIL import Image
5
+ import torch
6
+
7
+ app = Flask(__name__)
8
+
9
+ model = AutoModelForImageClassification.from_pretrained(
10
+ './myModel')
11
+ image_processor = AutoImageProcessor.from_pretrained(
12
+ "google/vit-base-patch16-224-in21k")
13
+
14
+
15
+ @app.route('/upload_image', methods=['POST'])
16
+ def upload_image():
17
+ # Get the image file from the request
18
+ image_file = request.files['image']
19
+
20
+ # Save the image file to a desired location on the server
21
+ image_path = "assets/img.jpg"
22
+ image_file.save(image_path)
23
+
24
+ # You can perform additional operations with the image here
25
+ # ...
26
+
27
+ return 'Image uploaded successfully'
28
+
29
+
30
+ @app.route('/get_text', methods=['GET'])
31
+ def get_text():
32
+ image = Image.open('assets/img.jpg')
33
+ inputs = image_processor(image, return_tensors="pt")
34
+
35
+ with torch.no_grad():
36
+ logits = model(**inputs).logits
37
+
38
+ predicted_label = logits.argmax(-1).item()
39
+
40
+ disease = model.config.id2label[predicted_label]
41
+
42
+ return disease
43
+
44
+
45
+ print('upload_image()')
46
+
47
+ # if __name__ == '__app__':
48
+ # app.run(host='192.168.1.7', port=5000 )
49
+ if __name__ == '__app__':
50
+ app.run( host='0.0.0.0',port=7860)
myModel/config.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "my_model",
3
+ "architectures": [
4
+ "ViTForImageClassification"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.0,
7
+ "encoder_stride": 16,
8
+ "hidden_act": "gelu",
9
+ "hidden_dropout_prob": 0.0,
10
+ "hidden_size": 768,
11
+ "id2label": {
12
+ "0": "Pepper__bell___Bacterial_spot",
13
+ "1": "Pepper__bell___healthy",
14
+ "2": "Potato___Early_blight",
15
+ "3": "Potato___Late_blight",
16
+ "4": "Potato___healthy",
17
+ "5": "Tomato_Bacterial_spot",
18
+ "6": "Tomato_Early_blight",
19
+ "7": "Tomato_Late_blight",
20
+ "8": "Tomato_Leaf_Mold",
21
+ "9": "Tomato_Septoria_leaf_spot",
22
+ "10": "Tomato_Spider_mites_Two_spotted_spider_mite",
23
+ "11": "Tomato__Target_Spot",
24
+ "12": "Tomato__Tomato_YellowLeaf__Curl_Virus",
25
+ "13": "Tomato__Tomato_mosaic_virus",
26
+ "14": "Tomato_healthy"
27
+ },
28
+ "image_size": 224,
29
+ "initializer_range": 0.02,
30
+ "intermediate_size": 3072,
31
+ "label2id": {
32
+ "Pepper__bell___Bacterial_spot": "0",
33
+ "Pepper__bell___healthy": "1",
34
+ "Potato___Early_blight": "2",
35
+ "Potato___Late_blight": "3",
36
+ "Potato___healthy": "4",
37
+ "Tomato_Bacterial_spot": "5",
38
+ "Tomato_Early_blight": "6",
39
+ "Tomato_Late_blight": "7",
40
+ "Tomato_Leaf_Mold": "8",
41
+ "Tomato_Septoria_leaf_spot": "9",
42
+ "Tomato_Spider_mites_Two_spotted_spider_mite": "10",
43
+ "Tomato__Target_Spot": "11",
44
+ "Tomato__Tomato_YellowLeaf__Curl_Virus": "12",
45
+ "Tomato__Tomato_mosaic_virus": "13",
46
+ "Tomato_healthy": "14"
47
+ },
48
+ "layer_norm_eps": 1e-12,
49
+ "model_type": "vit",
50
+ "num_attention_heads": 12,
51
+ "num_channels": 3,
52
+ "num_hidden_layers": 12,
53
+ "patch_size": 16,
54
+ "qkv_bias": true,
55
+ "torch_dtype": "float32",
56
+ "transformers_version": "4.26.1"
57
+ }
myModel/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:319df356e382a14d3cee2e0c0bf21c99faaf8f3e7017ef03c20adc01dcb6cc41
3
+ size 343305965
requirements.txt ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ altair==4.1.0
2
+ autopep8==1.7.0
3
+ biopython==1.79
4
+ blinker==1.6.2
5
+ certifi==2023.5.7
6
+ charset-normalizer==3.1.0
7
+ click==8.1.3
8
+ colorama==0.4.6
9
+ contourpy==1.0.6
10
+ cycler==0.11.0
11
+ docopt==0.6.2
12
+ filelock==3.12.0
13
+ Flask==2.3.2
14
+ fonttools==4.38.0
15
+ fsspec==2023.5.0
16
+ huggingface-hub==0.14.1
17
+ idna==3.4
18
+ itsdangerous==2.1.2
19
+ Jinja2==3.1.2
20
+ kiwisolver==1.4.4
21
+ MarkupSafe==2.1.2
22
+ matplotlib==3.6.1
23
+ mpmath==1.3.0
24
+ networkx==3.1
25
+ numpy==1.23.4
26
+ opencv-python==4.6.0.66
27
+ packaging==21.3
28
+ pandas==1.5.3
29
+ Pillow==9.3.0
30
+ pipreqs==0.4.13
31
+ pycodestyle==2.9.1
32
+ pyparsing==3.0.9
33
+ python-dateutil==2.8.2
34
+ pytz==2022.7.1
35
+ PyYAML==6.0
36
+ regex==2023.5.5
37
+ requests==2.31.0
38
+ scipy==1.9.3
39
+ six==1.16.0
40
+ sympy==1.12
41
+ tokenizers==0.13.3
42
+ toml==0.10.2
43
+ torch==2.0.1
44
+ tqdm==4.65.0
45
+ transformers==4.29.2
46
+ typing_extensions==4.5.0
47
+ urllib3==2.0.2
48
+ Werkzeug==2.3.4
49
+ yarg==0.1.9