dcavadia commited on
Commit
3a703d8
·
1 Parent(s): d200625

update app

Browse files
Files changed (2) hide show
  1. app.py +43 -24
  2. dat.json +64 -58
app.py CHANGED
@@ -1,33 +1,52 @@
1
  import json
2
- from keras.models import Model, load_model
3
- import gradio as gr
4
  import cv2
 
 
 
5
 
6
-
7
- model = load_model('model.h5', compile=True)
8
 
9
  # Opening JSON file
10
- f = open('dat.json')
11
-
12
- # returns JSON object as
13
- # a dictionary
14
- data = json.load(f)
15
 
16
  keys = list(data)
17
 
18
-
19
  def Predict(image):
20
- img = cv2.resize(image, (32,32)) / 255.0
21
- prediction = model.predict(img.reshape(1,32,32,3))
22
- print(prediction)
23
-
24
-
25
- return keys[prediction.argmax()],data[keys[prediction.argmax()]]['description'],data[keys[prediction.argmax()]]['symptoms'],data[keys[prediction.argmax()]]['causes'],data[keys[prediction.argmax()]]['treatement-1']
26
-
27
- demo=gr.Interface(fn=Predict,
28
- inputs="image",
29
- outputs=[gr.inputs.Textbox(label='Name Of Disease'),gr.inputs.Textbox(label='Description'),gr.inputs.Textbox(label='Symptoms'),gr.inputs.Textbox(label='Causes'),gr.inputs.Textbox(label='Treatement')],
30
- title="Skin Disease Classification",
31
- description='This Space predict these disease:\n \n1) Acne and Rosacea Photos. \n2) Actinic Keratosis Basal Cell Carcinoma and other Malignant Lesions.\n3) Eczema Photos. \n4) Melanoma Skin Cancer Nevi and Moles.\n5) Psoriasis pictures Lichen Planus and related diseases.\n6) Tinea Ringworm Candidiasis and other Fungal Infections.\n7) Urticaria Hives.\n8) Nail Fungus and other Nail Disease.\n')
32
-
33
- demo.launch(debug=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import json
 
 
2
  import cv2
3
+ import numpy as np
4
+ import gradio as gr
5
+ import onnxruntime
6
 
7
+ # Load the ONNX model
8
+ ort_session = onnxruntime.InferenceSession("modelonnx.onnx")
9
 
10
  # Opening JSON file
11
+ with open('dat.json') as f:
12
+ data = json.load(f)
 
 
 
13
 
14
  keys = list(data)
15
 
 
16
  def Predict(image):
17
+ # Preprocess the image
18
+ img = cv2.resize(image, (100, 100)) / 255.0
19
+
20
+ # Run inference with the ONNX model
21
+ input_name = ort_session.get_inputs()[0].name
22
+ output_name = ort_session.get_outputs()[0].name
23
+ result = ort_session.run([output_name], {input_name: img.reshape(1, 3, 100, 100).astype(np.float32)})[0]
24
+
25
+ # Get the index of the predicted class
26
+ prediction_idx = np.argmax(result)
27
+
28
+ # Debugging
29
+ print("Prediction Index:", prediction_idx)
30
+ print("Keys:", keys)
31
+
32
+ # Retrieve information from JSON based on the predicted class
33
+ disease_name = keys[prediction_idx]
34
+ description = data[disease_name]['description']
35
+ symptoms = data[disease_name]['symptoms']
36
+ causes = data[disease_name]['causes']
37
+ treatment = data[disease_name]['treatment-1']
38
+
39
+ return disease_name, description, symptoms, causes, treatment
40
+
41
+ # Define Gradio interface
42
+ demo = gr.Interface(fn=Predict,
43
+ inputs="image",
44
+ outputs=[gr.Textbox(label='Name Of Disease', type="text"),
45
+ gr.Textbox(label='Description', type="text"),
46
+ gr.Textbox(label='Symptoms', type="text"),
47
+ gr.Textbox(label='Causes', type="text"),
48
+ gr.Textbox(label='Treatment', type="text")],
49
+ title="Skin Disease Classification",
50
+ description='This Space predict these disease:\n \n1) Acne and Rosacea Photos. \n2) Actinic Keratosis Basal Cell Carcinoma and other Malignant Lesions.\n3) Eczema Photos. \n4) Melanoma Skin Cancer Nevi and Moles.\n5) Psoriasis pictures Lichen Planus and related diseases.\n6) Tinea Ringworm Candidiasis and other Fungal Infections.\n7) Urticaria Hives.\n8) Nail Fungus and other Nail Disease.\n')
51
+
52
+ demo.launch(debug=True)
dat.json CHANGED
@@ -1,59 +1,65 @@
1
  {
2
- "acne/rosacea": {
3
- "description": "Acne, also known as acne vulgaris, is a long-term skin disease that occurs when hair follicles are clogged with dead skin cells and oil from the skin.[10] It is characterized by blackheads or whiteheads, pimples, oily skin, and possible scarring.",
4
- "symptoms": "Scars and Pigmentation",
5
- "causes": "Risk factors for the development of acne, other than genetics, have not been conclusively identified. Possible secondary contributors include hormones, infections, diet and stress",
6
- "treatement-1": "https://www.medicinenet.com/acne/article.htm#what_is_acne",
7
- "treatement-2": "https://www.aad.org/public/diseases/acne-and-rosacea/rosacea/how-to-treat-the-redness"
8
- },
9
- "actinic_keratosos/basal_cell_carcinoma": {
10
- "description": "Actinic keratosis (AK) is a pre-cancerous[2] area of thick, scaly, or crusty skin.[3][4] These growths are more common in fair-skinned people and those who are frequently in the sun.[5] They are believed to form when skin gets damaged by ultraviolet (UV) radiation from the sun or indoor tanning beds, usually over the course of decades.",
11
- "symptoms": "Actinic keratoses (AKs) most commonly present as a white, scaly plaque of variable thickness with surrounding redness",
12
- "causes": "The most important cause of AK formation is solar radiation, through a variety of mechanisms. ",
13
- "treatement-1": "https://www.skincancer.org/skin-cancer-information/actinic-keratosis/actinic-keratosis-treatment-options",
14
- "treatement-2": "https://www.skincancer.org/skin-cancer-information/basal-cell-carcinoma/bcc-treatment-options"
15
- },
16
- "eczema": {
17
- "description": "Dermatitis, also known as eczema, is a group of diseases that results in inflammation of the skin.[1] These diseases are characterized by itchiness, red skin and a rash.[1] In cases of short duration, there may be small blisters, while in long-term cases the skin may become thickened.[1] The area of skin involved can vary from small to the entire body.",
18
- "symptoms": "The symptoms of atopic dermatitis vary from person to person, the most common symptoms are dry, itchy, red skin. Typical affected skin areas include the folds of the arms, the back of the knees, wrists, face and hands. Perioral dermatitis refers to a red bumpy rash around the mouth.",
19
- "causes": "The cause of dermatitis is unknown but is presumed to be a combination of genetic and environmental factors.",
20
- "treatement-1": "https://www.medicalnewstoday.com/articles/14417.php",
21
- "treatement-2": "https://nationaleczema.org/eczema/treatment/"
22
- },
23
- "melanma/nevi/moles": {
24
- "description": "Melanoma, also known as malignant melanoma, is a type of cancer that develops from the pigment-containing cells known as melanocytes.[1] Melanomas typically occur in the skin, but may rarely occur in the mouth, intestines, or eye.",
25
- "symptoms": "Early signs of melanoma are changes to the shape or color of existing moles or, in the case of nodular melanoma, the appearance of a new lump anywhere on the skin. At later stages, the mole may itch, ulcerate or bleed. Early signs of melanoma are summarized by the mnemonic ABCDEF Asymmetry Borders (irregular with edges and corners) Color (variegated) Diameter (greater than 6 mm (0.24 in), about the size of a pencil eraser) Evolving over time Funny looking",
26
- "causes": "Melanomas are usually caused by DNA damage resulting from exposure to ultraviolet light from the sun. Genetics also plays a role.",
27
- "treatement-1": "https://www.cancer.org/cancer/melanoma-skin-cancer/treating/by-stage.html",
28
- "treatement-2": "https://www.melanoma.org/understand-melanoma/melanoma-treatment"
29
- },
30
- "psoriasis/lichen": {
31
- "description": "Psoriasis is a long-lasting autoimmune disease characterized by patches of abnormal skin.[6] These skin patches are typically red, dry, itchy, and scaly.[3] On people with darker skin the patches may be purple in colour.",
32
- "symptoms": "Plaque psoriasis typically appears as raised areas of inflamed skin covered with silvery-white scaly skin. These areas are called plaques and are most commonly found on the elbows, knees, scalp, and back.",
33
- "causes": "The cause of psoriasis is not fully understood, but a number of theories exist.",
34
- "treatement-1": "https://www.medicinenet.com/psoriasis/article.htm",
35
- "treatement-2": "https://www.mayoclinic.org/diseases-conditions/psoriasis/diagnosis-treatment/drc-20355845"
36
- },
37
- "tinea_ringworm/candidiasis": {
38
- "description": "Candidiasis is a fungal infection due to any type of Candida (a type of yeast).[2] When it affects the mouth, it is commonly called thrush.[2] Signs and symptoms include white patches on the tongue or other areas of the mouth and throat.[3] Other symptoms may include soreness and problems swallowing",
39
- "symptoms": "Signs and symptoms of candidiasis vary depending on the area affected.[17] Most candidal infections result in minimal complications such as redness, itching, and discomfort, though complications may be severe or even fatal if left untreated in certain populations.",
40
- "causes": "Candida yeasts are generally present in healthy humans, frequently part of the human body's normal oral and intestinal flora, and particularly on the skin; however, their growth is normally limited by the human immune system and by competition of other microorganisms, such as bacteria occupying the same locations in the human body.",
41
- "treatement-1": "https://www.cdc.gov/fungal/diseases/candidiasis/thrush/index.html",
42
- "treatement-2": "https://www.drugs.com/health-guide/candidiasis.html"
43
- },
44
- "urticaria/hives": {
45
- "description": "Hives, also known as urticaria, is a kind of skin rash with red, raised, itchy bumps.[1] They may also burn or sting.[2] Often the patches of rash move around.[2] Typically they last a few days and do not leave any long-lasting skin changes.",
46
- "symptoms": "Welts (raised areas surrounded by a red base) from hives can appear anywhere on the surface of the skin. Whether the trigger is allergic or not, a complex release of inflammatory mediators, including histamine from cutaneous mast cells, results in fluid leakage from superficial blood vessels.",
47
- "causes": "Hives can also be classified by the purported causative agent. Many different substances in the environment may cause hives, including medications, food and physical agents. In perhaps more than 50% of people with chronic hives of unknown cause, it is due to an autoimmune reaction.[6]",
48
- "treatement-1": "https://www.webmd.com/skin-problems-and-treatments/guide/hives-urticaria-angioedema",
49
- "treatement-2": "https://acaai.org/allergies/types-allergies/hives-urticaria"
50
- },
51
- "nail_fungus": {
52
- "description": "A nail disease or onychosis is a disease or deformity of the nail. Although the nail is a structure produced by the skin and is a skin appendage, nail diseases have a distinct classification as they have their own signs and symptoms which may relate to other medical conditions. Some nail conditions that show signs of infection or inflammation may require medical assistance.",
53
- "symptoms": "You may have nail fungus if one or more of your nails are: Thickened, Whitish to yellow-brown discoloration, Brittle, crumbly or ragged, Distorted in shape, A dark color, caused by debris building up under your nail, Smelling slightly foul",
54
- "causes": "Fungal nail infections are caused by various fungal organisms (fungi). The most common cause is a type of fungus called dermatophyte. Yeast and molds also can cause nail infections.",
55
- "treatement-1": "https://www.mayoclinic.org/diseases-conditions/nail-fungus/symptoms-causes/syc-20353294",
56
- "treatement-2": "https://www.healthline.com/health/fungal-nail-infection#prevention"
57
- }
58
-
59
- }
 
 
 
 
 
 
 
1
  {
2
+ "actinic keratosis": {
3
+ "description": "Actinic keratosis (AK) is a pre-cancerous area of thick, scaly, or crusty skin. These growths are more common in fair-skinned people and those who are frequently in the sun. They are believed to form when skin gets damaged by ultraviolet (UV) radiation from the sun or indoor tanning beds, usually over the course of decades.",
4
+ "symptoms": "Actinic keratoses (AKs) most commonly present as a white, scaly plaque of variable thickness with surrounding redness",
5
+ "causes": "The most important cause of AK formation is solar radiation, through a variety of mechanisms.",
6
+ "treatment-1": "https://www.skincancer.org/skin-cancer-information/actinic-keratosis/actinic-keratosis-treatment-options",
7
+ "treatment-2": "https://www.skincancer.org/skin-cancer-information/basal-cell-carcinoma/bcc-treatment-options"
8
+ },
9
+ "basal cell carcinoma": {
10
+ "description": "Basal cell carcinoma (BCC) is the most common type of skin cancer. Basal cell carcinoma occurs when one of the skin's basal cells develops a mutation in its DNA. Basal cells are found at the bottom of the epidermis the outermost layer of skin.",
11
+ "symptoms": "Basal cell carcinomas often look like open sores, red patches, pink growths, shiny bumps, or scars. In some cases, a crusty area bleeds or oozes, but usually, there is little or no sensation.",
12
+ "causes": "The exact cause of basal cell carcinoma is unknown, but several risk factors may increase your chances of developing the disease. Ultraviolet (UV) radiation from the sun is the main cause of basal cell carcinoma.",
13
+ "treatment-1": "https://www.skincancer.org/skin-cancer-information/basal-cell-carcinoma/bcc-treatment-options",
14
+ "treatment-2": "https://www.cancer.gov/types/skin/patient/skin-treatment-pdq"
15
+ },
16
+ "dermatofibroma": {
17
+ "description": "A dermatofibroma is a common benign skin lesion that occurs most often on the extremities of adults. These lesions are considered tumors of the skin and soft tissue and are composed of fibroblastic cells (cells that produce the protein collagen).",
18
+ "symptoms": "Dermatofibromas are typically small, firm, red-brown bumps that are found most frequently on the legs, but can appear on other parts of the body as well.",
19
+ "causes": "The exact cause of dermatofibromas is not known, but they may develop after an insect bite or minor injury to the skin.",
20
+ "treatment-1": "https://www.aad.org/public/diseases/bumps-and-growths/dermatofibroma",
21
+ "treatment-2": "https://emedicine.medscape.com/article/1056744-overview"
22
+ },
23
+ "melanoma": {
24
+ "description": "Melanoma is a type of skin cancer that develops from the pigment-producing cells known as melanocytes. Melanomas typically occur in the skin but may rarely occur in the mouth, intestines, or eye.",
25
+ "symptoms": "Early signs of melanoma are changes to the shape or color of existing moles or the appearance of a new lump anywhere on the skin. At later stages, the mole may itch, ulcerate, or bleed.",
26
+ "causes": "Melanomas are usually caused by DNA damage resulting from exposure to ultraviolet (UV) light from the sun. Genetics also play a role.",
27
+ "treatment-1": "https://www.cancer.org/cancer/melanoma-skin-cancer/treating/by-stage.html",
28
+ "treatment-2": "https://www.melanoma.org/understand-melanoma/melanoma-treatment"
29
+ },
30
+ "nevus": {
31
+ "description": "A nevus is a common, benign growth or birthmark that develops on the skin due to a proliferation of melanocytes, the cells that produce skin pigment.",
32
+ "symptoms": "Nevi can vary greatly in appearance, ranging from flat, pigmented spots to raised, hairy moles. Most nevi are harmless and require no treatment, but some may need to be monitored or removed if they show signs of change or become cancerous.",
33
+ "causes": "The exact cause of nevi is not known, but they are believed to develop as a result of genetic predisposition and exposure to ultraviolet (UV) radiation from the sun.",
34
+ "treatment-1": "https://www.aad.org/public/diseases/bumps-and-growths/nevi",
35
+ "treatment-2": "https://www.skincancer.org/skin-cancer-information/melanoma/moles-and-melanoma"
36
+ },
37
+ "pigmented benign keratosis": {
38
+ "description": "Pigmented benign keratoses are common benign skin lesions that often develop as people age. These lesions typically appear as raised, scaly patches on sun-exposed areas of the skin, such as the face, neck, arms, and hands.",
39
+ "symptoms": "Pigmented benign keratoses usually present as small, brown or black spots with a rough texture. They may be mistaken for melanoma or other types of skin cancer, so it's important to have them evaluated by a dermatologist.",
40
+ "causes": "The exact cause of pigmented benign keratoses is not known, but they are thought to develop as a result of cumulative sun exposure and genetic predisposition.",
41
+ "treatment-1": "https://www.dermnetnz.org/topics/solar-keratosis",
42
+ "treatment-2": "https://www.skincancer.org/skin-cancer-information/solar-keratosis/solar-keratosis-treatment-options"
43
+ },
44
+ "seborrheic keratosis": {
45
+ "description": "Seborrheic keratosis is a common, non-cancerous skin growth that typically appears as a waxy, brown, or black growth on the face, chest, shoulders, or back. These growths are usually painless and do not require treatment unless they become irritated or cosmetically bothersome.",
46
+ "symptoms": "Seborrheic keratoses are often mistaken for moles or warts but have a distinct appearance characterized by a waxy, stuck-on appearance.",
47
+ "causes": "The exact cause of seborrheic keratoses is not known, but they are thought to develop as a result of genetic predisposition and cumulative sun exposure.",
48
+ "treatment-1": "https://www.aad.org/public/diseases/bumps-and-growths/seborrheic-keratoses",
49
+ "treatment-2": "https://www.healthline.com/health/seborrheic-keratosis-removal"
50
+ },
51
+ "squamous cell carcinoma": {
52
+ "description": "Squamous cell carcinoma (SCC) is a common type of skin cancer that develops in the squamous cells that make up the outer layer of the skin. SCC often appears as a red, scaly patch or a raised, wart-like growth that may crust or bleed.",
53
+ "symptoms": "Early signs of SCC include persistent sores, rough scaly patches, or elevated growths that may crust or bleed. If left untreated, SCC can grow deeper into the skin and spread to other parts of the body, leading to serious complications.",
54
+ "causes": "The primary cause of SCC is cumulative exposure to ultraviolet (UV) radiation from the sun. Other risk factors include fair skin, a history of sunburns, a weakened immune system, and exposure to certain chemicals or radiation.",
55
+ "treatment-1": "https://www.skincancer.org/skin-cancer-information/squamous-cell-carcinoma/",
56
+ "treatment-2": "https://www.cancer.org/cancer/squamous-cell-skin-cancer/treating/by-stage.html"
57
+ },
58
+ "vascular lesion": {
59
+ "description": "Vascular lesions are abnormal clusters of blood vessels that can appear on the skin's surface. These lesions can be categorized as either vascular tumors or vascular malformations, depending on their structure and behavior.",
60
+ "symptoms": "The symptoms of vascular lesions can vary depending on their type and location. Common symptoms include red or purple discoloration, swelling, pain, and changes in skin texture.",
61
+ "causes": "The exact cause of vascular lesions is not always known, but they are believed to result from abnormal development or damage to blood vessels during fetal development, injury, or other underlying medical conditions.",
62
+ "treatment-1": "https://www.mayoclinic.org/diseases-conditions/hemangioma/symptoms-causes/syc-20372935",
63
+ "treatment-2": "https://www.webmd.com/skin-problems-and-treatments/guide/vascular-lesions#1"
64
+ }
65
+ }