tmabraham commited on
Commit
641bdbe
·
verified ·
1 Parent(s): 9260301

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -21
app.py CHANGED
@@ -27,7 +27,7 @@ GLEASON_LABELS = {
27
 
28
  }
29
  BACH_LABELS = {0: "Benign",
30
- 1: "InSitu",
31
  2:"Invasive",
32
  3: "Normal"}
33
  CRC_LABELS = {
@@ -194,13 +194,13 @@ def predict_class(image, linear, dataset):
194
  breakhis = gr.Interface(
195
  fn=predict_breakhis,
196
  inputs=gr.Image(type="filepath", label="Upload Breast Histopathology Image"),
197
- outputs=gr.Label(num_top_classes=4, label="Tumor Type Prediction"),
198
- title="BreakHis Breast Tumor Classification",
199
  description="""
200
- Upload a breast histopathology image to predict the tumor type. Your image must be at 40X magnification, and ideally between 224x224 and 700x460 resolution. Do not otherwise modify your image.
201
 
202
- This model uses a custom-trained DinoV2 foundation model for pathology images
203
- with a linear classifier for BreakHis tumor classification.
204
 
205
  **Tumor Types:**
206
  - **Benign tumors:** Tubular Adenoma (TA), Fibroadenoma (F)
@@ -208,6 +208,8 @@ breakhis = gr.Interface(
208
 
209
  These 4 classes were selected from the full BreakHis dataset as they have sufficient patient counts (≥7 patients) for robust evaluation.
210
  For this particular demo, images *must* be one of the sample classes - unsupported classes will yield confusing and/or useless results.
 
 
211
  """,
212
  examples=["./SOB_B_TA-14-13200-40-001.png",
213
  "./SOB_M_MC-14-10147-40-001.png",
@@ -219,17 +221,19 @@ breakhis = gr.Interface(
219
  gleason = gr.Interface(
220
  fn=predict_gleason,
221
  inputs=gr.Image(type="filepath", label="Upload Prostate Cancer Image"),
222
- outputs=gr.Label(num_top_classes=4, label="Gleason Tumor Type Prediction"),
223
- title="Gleason Prostate Tumor Classification",
224
  description="""
225
  Upload a prostate cancer image to predict the tumor type. Your image must be at 40X magnification, and ideally between 224x224 and 750x750 resolution. Do not otherwise modify your image.
226
 
227
- This model uses a custom-trained DinoV2 foundation model for pathology images
228
- with a linear classifier for gleason tumor classification.
229
 
230
  Images are classified as benign, Gleason pattern 3, 4 or 5.
231
 
232
  For this particular demo, images *must* be one of the sample classes - unsupported classes will yield confusing and/or useless results.
 
 
233
  """,
234
  examples=["./ZT111_4_A_1_12_patch_13_class_2.jpg",
235
  "./ZT204_6_A_1_10_patch_10_class_3.jpg",
@@ -242,16 +246,18 @@ crc = gr.Interface(
242
  fn=predict_crc,
243
  inputs=gr.Image(type="filepath", label="Upload Colorectal Cancer Image"),
244
  outputs=gr.Label(num_top_classes=9, label="CRC Tumor Type Prediction"),
245
- title="Colorectal Tumor Classification",
246
  description="""
247
- Upload a colorectal cancer image to predict the tumor type. Your image must be at 20X magnification, and ideally at 224x224. Do not otherwise modify your image.
248
 
249
- This model uses a custom-trained DinoV2 foundation model for pathology images
250
- with a linear classifier for colorectal tumor classification.
251
 
252
  The tissue classes are: Adipose (ADI), background (BACK), debris (DEB), lymphocytes (LYM), mucus (MUC), smooth muscle (MUS), normal colon mucosa (NORM), cancer-associated stroma (STR) and colorectal adenocarcinoma epithelium (TUM)
253
 
254
  For this particular demo, images *must* be one of the sample classes - unsupported classes will yield confusing and/or useless results.
 
 
255
  """,
256
  examples=["./ADI-TCGA-AAICEQFN.png",
257
  "./BACK-TCGA-AARRNSTS.png",
@@ -263,17 +269,19 @@ crc = gr.Interface(
263
  bach = gr.Interface(
264
  fn=predict_bach,
265
  inputs=gr.Image(type="filepath", label="Upload Cancer Image"),
266
- outputs=gr.Label(num_top_classes=4, label="Bach Tumor Type Prediction"),
267
- title="Tumor Classification",
268
  description="""
269
  Upload a breast cancer image to predict the tumor type. Your image must be at 20X magnification, and ideally between 224x224 and 1536x2048 resolution. Do not otherwise modify your image.
270
 
271
- This model uses a custom-trained DinoV2 foundation model for pathology images
272
  with a linear classifier for tumor classification.
273
 
274
- Images are classified as benign, normal, invasive, inSitu
275
 
276
  For this particular demo, images *must* be one of the sample classes - unsupported classes will yield confusing and/or useless results.
 
 
277
  """,
278
  examples=["./b001.png",
279
  "./n001.png",
@@ -285,17 +293,20 @@ bach = gr.Interface(
285
  bracs = gr.Interface(
286
  fn=predict_bracs,
287
  inputs=gr.Image(type="filepath", label="Upload Cancer Image"),
288
- outputs=gr.Label(num_top_classes=7, label="Bracs Tumor Type Prediction"),
289
- title="Tumor Classification",
290
  description="""
291
  Upload a breast cancer image to predict the tumor type. Your image must be at 40X magnification. Do not otherwise modify your image.
292
 
293
- This model uses a custom-trained DinoV2 foundation model for pathology images with a linear classifier for tumor classification.
 
294
 
295
  Images are classified as Normal, Pathological Benign, Usual Ductal Hyperplasia, Flat Epithelial Atypia,
296
  Atypical Ductal Hyperplasia, Ductal Carcinoma In Situ, Invasive Carcinoma
297
 
298
  For this particular demo, images *must* be one of the sample classes - unsupported classes will yield confusing and/or useless results.
 
 
299
  """,
300
  examples=[
301
  ], # You can add example image paths here
 
27
 
28
  }
29
  BACH_LABELS = {0: "Benign",
30
+ 1: "In Situ",
31
  2:"Invasive",
32
  3: "Normal"}
33
  CRC_LABELS = {
 
194
  breakhis = gr.Interface(
195
  fn=predict_breakhis,
196
  inputs=gr.Image(type="filepath", label="Upload Breast Histopathology Image"),
197
+ outputs=gr.Label(num_top_classes=4, label="BreakHis Breast Cancer Classification"),
198
+ title="BreakHis Breast Cancer Classification",
199
  description="""
200
+ Upload a breast histopathology image to predict the breast cancer subtype. Your image must be at 40X magnification, and ideally between 224x224 and 700x460 resolution. Do not otherwise modify your image.
201
 
202
+ This demo uses a custom-trained DINOv2 foundation model for pathology images called [OpenMidnight](https://sophont.med/blog/openmidnight)
203
+ with a linear classifier for BreakHis breast cancer classification.
204
 
205
  **Tumor Types:**
206
  - **Benign tumors:** Tubular Adenoma (TA), Fibroadenoma (F)
 
208
 
209
  These 4 classes were selected from the full BreakHis dataset as they have sufficient patient counts (≥7 patients) for robust evaluation.
210
  For this particular demo, images *must* be one of the sample classes - unsupported classes will yield confusing and/or useless results.
211
+
212
+ This demonstration is for illustrative purposes only and should not be used for diagnostic/clinical purposes.
213
  """,
214
  examples=["./SOB_B_TA-14-13200-40-001.png",
215
  "./SOB_M_MC-14-10147-40-001.png",
 
221
  gleason = gr.Interface(
222
  fn=predict_gleason,
223
  inputs=gr.Image(type="filepath", label="Upload Prostate Cancer Image"),
224
+ outputs=gr.Label(num_top_classes=4, label="Gleason Grading"),
225
+ title="Gleason Grading",
226
  description="""
227
  Upload a prostate cancer image to predict the tumor type. Your image must be at 40X magnification, and ideally between 224x224 and 750x750 resolution. Do not otherwise modify your image.
228
 
229
+ This demo uses a custom-trained DINOv2 foundation model for pathology images called [OpenMidnight](https://sophont.med/blog/openmidnight)
230
+ with a linear classifier for Gleason grading.
231
 
232
  Images are classified as benign, Gleason pattern 3, 4 or 5.
233
 
234
  For this particular demo, images *must* be one of the sample classes - unsupported classes will yield confusing and/or useless results.
235
+
236
+ This demonstration is for illustrative purposes only and should not be used for diagnostic/clinical purposes.
237
  """,
238
  examples=["./ZT111_4_A_1_12_patch_13_class_2.jpg",
239
  "./ZT204_6_A_1_10_patch_10_class_3.jpg",
 
246
  fn=predict_crc,
247
  inputs=gr.Image(type="filepath", label="Upload Colorectal Cancer Image"),
248
  outputs=gr.Label(num_top_classes=9, label="CRC Tumor Type Prediction"),
249
+ title="Colorectal Cancer Tissue Classification",
250
  description="""
251
+ Upload a colorectal cancer image to predict the tissue class. Your image must be at 20X magnification, and ideally at 224x224. Do not otherwise modify your image.
252
 
253
+ This demo uses a custom-trained DINOv2 foundation model for pathology images called [OpenMidnight](https://sophont.med/blog/openmidnight)
254
+ with a linear classifier for colorectal cancer tissue classification.
255
 
256
  The tissue classes are: Adipose (ADI), background (BACK), debris (DEB), lymphocytes (LYM), mucus (MUC), smooth muscle (MUS), normal colon mucosa (NORM), cancer-associated stroma (STR) and colorectal adenocarcinoma epithelium (TUM)
257
 
258
  For this particular demo, images *must* be one of the sample classes - unsupported classes will yield confusing and/or useless results.
259
+
260
+ This demonstration is for illustrative purposes only and should not be used for diagnostic/clinical purposes.
261
  """,
262
  examples=["./ADI-TCGA-AAICEQFN.png",
263
  "./BACK-TCGA-AARRNSTS.png",
 
269
  bach = gr.Interface(
270
  fn=predict_bach,
271
  inputs=gr.Image(type="filepath", label="Upload Cancer Image"),
272
+ outputs=gr.Label(num_top_classes=4, label="BACH Breast Cancer Classification"),
273
+ title="BACH Breast Cancer Classification",
274
  description="""
275
  Upload a breast cancer image to predict the tumor type. Your image must be at 20X magnification, and ideally between 224x224 and 1536x2048 resolution. Do not otherwise modify your image.
276
 
277
+ This demo uses a custom-trained DINOv2 foundation model for pathology images called [OpenMidnight](https://sophont.med/blog/openmidnight)
278
  with a linear classifier for tumor classification.
279
 
280
+ Images are classified as benign, normal, invasive, in-situ.
281
 
282
  For this particular demo, images *must* be one of the sample classes - unsupported classes will yield confusing and/or useless results.
283
+
284
+ This demonstration is for illustrative purposes only and should not be used for diagnostic/clinical purposes.
285
  """,
286
  examples=["./b001.png",
287
  "./n001.png",
 
293
  bracs = gr.Interface(
294
  fn=predict_bracs,
295
  inputs=gr.Image(type="filepath", label="Upload Cancer Image"),
296
+ outputs=gr.Label(num_top_classes=7, label="BRACS Tumor Subtyping"),
297
+ title="BRACS Tumor Subtyping",
298
  description="""
299
  Upload a breast cancer image to predict the tumor type. Your image must be at 40X magnification. Do not otherwise modify your image.
300
 
301
+ This demo uses a custom-trained DINOv2 foundation model for pathology images called [OpenMidnight](https://sophont.med/blog/openmidnight)
302
+ with a linear classifier for tumor classification.
303
 
304
  Images are classified as Normal, Pathological Benign, Usual Ductal Hyperplasia, Flat Epithelial Atypia,
305
  Atypical Ductal Hyperplasia, Ductal Carcinoma In Situ, Invasive Carcinoma
306
 
307
  For this particular demo, images *must* be one of the sample classes - unsupported classes will yield confusing and/or useless results.
308
+
309
+ This demonstration is for illustrative purposes only and should not be used for diagnostic/clinical purposes.
310
  """,
311
  examples=[
312
  ], # You can add example image paths here