Jyothirmai commited on
Commit
9e98a91
1 Parent(s): e5a0b2d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -17
app.py CHANGED
@@ -45,20 +45,26 @@ with gr.Row():
45
  generate_button = gr.Button("Generate Caption")
46
 
47
 
48
- real_captions = {"1" : "No acute cardiopulmonary abnormality. Low lung volumes. Heart size and mediastinal contour within normal limits. No focal air space consolidation, pneumothorax, or pleural effusion. Mild thoracic spine degenerative change.",
49
- "2":"Left basilar atelectasis and/or infiltrate, with no radiographic evidence of tuberculosis. Heart size upper limits of normal. Small amount of left basilar airspace disease. The right lung is clear. There are no cavitary lesions seen. No pneumothorax. No pleural effusions",
50
- "3":"Cardiomegaly and small bilateral pleural effusions. Abnormal pulmonary opacities most suggestive of pulmonary edema, primary differential diagnosis includes infection and aspiration, clinical correlation recommended Moderate-to-marked enlargement of the cardiac silhouette, mediastinal contours appear similar to prior. Mild bilateral posterior sulcus blunting, interstitial and alveolar opacities greatest in the central lungs and bases with indistinct vascular margination.",
51
- "4":"Severe cardiomegaly. Limited mediastinal evaluation given body habitus and lordotic projection. Recommend XXXX for further evaluation of mediastinum given T/Spine injury noted on C/Spine imaging. Critical result notification documented through Primordial. Lordotic projection and large body habitus. Limited mediastinal evaluation. Severe cardiomegaly. No visualized pneumothorax. No large effusion or airspace disease. No fracture."}
 
 
 
 
52
 
53
- imgIDs = {"1":"/content/drive/MyDrive/cnn-rnn/NLMCXR_png/CXR192_IM-0598_0",
 
 
 
 
54
  "2":"/content/drive/MyDrive/cnn-rnn/NLMCXR_png/CXR194_IM-0609_0",
55
  "3":"/content/drive/MyDrive/cnn-rnn/NLMCXR_png/CXR2637_IM-1122_0",
56
  "4":"/content/drive/MyDrive/cnn-rnn/NLMCXR_png/CXR1111_IM-0077_0"}
57
-
58
-
59
- caption = gr.Textbox(label="Generated Caption")
60
- real_caption = gr.Textbox(label="Actual Caption")
61
-
62
  def predict(img, model_name, max_tokens, temperature, imgID):
63
  if model_name == "CLIP-GPT2":
64
  return generate_caption_clipgpt(img, max_tokens, temperature), getCaption(imgID)
@@ -73,14 +79,10 @@ def predict(img, model_name, max_tokens, temperature, imgID):
73
  else:
74
  return "select a model","select an image"
75
 
76
- def getCaption(imgID):
77
- print(real_captions[imgID])
78
- return real_captions[imgID]
79
-
80
- def getImageID(imgID):
81
- print(imgIDs[imgID])
82
- return imgIDs[imgID]
83
 
 
 
 
84
  examples = [[f"example{i}.jpg"] for i in range(1,7)]
85
 
86
  description= "You can generate captions by uploading an X-Ray and selecting a model of your choice below. Please select the number of Max Tokens and Temperature setting, if you are testing CLIP GPT2 and VIT GPT2 Models"
 
45
  generate_button = gr.Button("Generate Caption")
46
 
47
 
48
+ caption = gr.Textbox(label="Generated Caption")
49
+ real_caption = gr.Textbox(label="Actual Caption")
50
+
51
+ def getCaption(imgID):
52
+ real_captions = {"1" : "No acute cardiopulmonary abnormality. Low lung volumes. Heart size and mediastinal contour within normal limits. No focal air space consolidation, pneumothorax, or pleural effusion. Mild thoracic spine degenerative change.",
53
+ "2":"Left basilar atelectasis and/or infiltrate, with no radiographic evidence of tuberculosis. Heart size upper limits of normal. Small amount of left basilar airspace disease. The right lung is clear. There are no cavitary lesions seen. No pneumothorax. No pleural effusions",
54
+ "3":"Cardiomegaly and small bilateral pleural effusions. Abnormal pulmonary opacities most suggestive of pulmonary edema, primary differential diagnosis includes infection and aspiration, clinical correlation recommended Moderate-to-marked enlargement of the cardiac silhouette, mediastinal contours appear similar to prior. Mild bilateral posterior sulcus blunting, interstitial and alveolar opacities greatest in the central lungs and bases with indistinct vascular margination.",
55
+ "4":"Severe cardiomegaly. Limited mediastinal evaluation given body habitus and lordotic projection. Recommend XXXX for further evaluation of mediastinum given T/Spine injury noted on C/Spine imaging. Critical result notification documented through Primordial. Lordotic projection and large body habitus. Limited mediastinal evaluation. Severe cardiomegaly. No visualized pneumothorax. No large effusion or airspace disease. No fracture."}
56
 
57
+ print(real_captions[imgID])
58
+ return real_captions[imgID]
59
+
60
+ def getImageID(imgID):
61
+ imgIDs = {"1":"/content/drive/MyDrive/cnn-rnn/NLMCXR_png/CXR192_IM-0598_0",
62
  "2":"/content/drive/MyDrive/cnn-rnn/NLMCXR_png/CXR194_IM-0609_0",
63
  "3":"/content/drive/MyDrive/cnn-rnn/NLMCXR_png/CXR2637_IM-1122_0",
64
  "4":"/content/drive/MyDrive/cnn-rnn/NLMCXR_png/CXR1111_IM-0077_0"}
65
+ print(imgIDs[imgID])
66
+ return imgIDs[imgID]
67
+
 
 
68
  def predict(img, model_name, max_tokens, temperature, imgID):
69
  if model_name == "CLIP-GPT2":
70
  return generate_caption_clipgpt(img, max_tokens, temperature), getCaption(imgID)
 
79
  else:
80
  return "select a model","select an image"
81
 
 
 
 
 
 
 
 
82
 
83
+
84
+ #main call
85
+
86
  examples = [[f"example{i}.jpg"] for i in range(1,7)]
87
 
88
  description= "You can generate captions by uploading an X-Ray and selecting a model of your choice below. Please select the number of Max Tokens and Temperature setting, if you are testing CLIP GPT2 and VIT GPT2 Models"