msabia commited on
Commit
361d0b6
·
verified ·
1 Parent(s): dc7735e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -26
app.py CHANGED
@@ -58,30 +58,31 @@ def searchEmbeddings(id, mod1, mod2):
58
  image10 = get_image(dataset_image1, dataset_image2, dataset_image_mask, processid_to_index, I[0][9])
59
 
60
  # get taxonomic information
61
- s0 = getTax(original_indx)
62
- s1 = getTax(I[0][0])
63
- s2 = getTax(I[0][1])
64
- s3 = getTax(I[0][2])
65
- s4 = getTax(I[0][3])
66
- s5 = getTax(I[0][4])
67
- s6 = getTax(I[0][5])
68
- s7 = getTax(I[0][6])
69
- s8 = getTax(I[0][7])
70
- s9 = getTax(I[0][8])
71
- s10 = getTax(I[0][9])
72
 
73
- return id_list, image0, image1, image2, image3, image4, image5, image6, image7, image8, image9, image10, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10
 
74
 
75
  def getRandID():
76
  indx = random.randrange(0, 325667)
77
  return indx_to_id_dict[indx], indx
78
 
79
- def getTax(indx):
80
- s = species[indx]
81
- g = genus[indx]
82
- f = family[indx]
83
- str = "Species: " + s + "\nGenus: " + g + "\nFamily: " + f
84
- return str
85
 
86
  with gr.Blocks(title="Bioscan-Clip") as demo:
87
  # open general files
@@ -107,12 +108,12 @@ with gr.Blocks(title="Bioscan-Clip") as demo:
107
  id_to_dna_emb_dict = pickle.load(f)
108
 
109
  # open taxonomy files
110
- with open("family.pickle", "rb") as f:
111
- family = [item.decode("utf-8") for item in pickle.load(f)]
112
- with open("genus.pickle", "rb") as f:
113
- genus= [item.decode("utf-8") for item in pickle.load(f)]
114
- with open("species.pickle", "rb") as f:
115
- species = [item.decode("utf-8") for item in pickle.load(f)]
116
 
117
  with gr.Column():
118
  process_id = gr.Textbox(label="ID:", info="Enter a sample ID to search for")
@@ -168,8 +169,8 @@ with gr.Blocks(title="Bioscan-Clip") as demo:
168
 
169
  id_btn.click(fn=getRandID, inputs=[], outputs=[rand_id, rand_id_indx])
170
  search_btn.click(fn=searchEmbeddings, inputs=[process_id, mod1, mod2],
171
- outputs=[process_id_list, image0, image1, image2, image3, image4, image5, image6, image7, image8, image9, image10,
172
- tax0, tax1, tax2, tax3, tax4, tax5, tax6, tax7, tax8, tax9, tax10])
173
  examples = gr.Examples(
174
  examples=[["ABOTH966-22", "DNA", "DNA"],
175
  ["CRTOB8472-22", "DNA", "Image"],
 
58
  image10 = get_image(dataset_image1, dataset_image2, dataset_image_mask, processid_to_index, I[0][9])
59
 
60
  # get taxonomic information
61
+ # s0 = getTax(original_indx)
62
+ # s1 = getTax(I[0][0])
63
+ # s2 = getTax(I[0][1])
64
+ # s3 = getTax(I[0][2])
65
+ # s4 = getTax(I[0][3])
66
+ # s5 = getTax(I[0][4])
67
+ # s6 = getTax(I[0][5])
68
+ # s7 = getTax(I[0][6])
69
+ # s8 = getTax(I[0][7])
70
+ # s9 = getTax(I[0][8])
71
+ # s10 = getTax(I[0][9])
72
 
73
+ return id_list, image0, image1, image2, image3, image4, image5, image6, image7, image8, image9, image10
74
+ #s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10
75
 
76
  def getRandID():
77
  indx = random.randrange(0, 325667)
78
  return indx_to_id_dict[indx], indx
79
 
80
+ # def getTax(indx):
81
+ # s = species[indx]
82
+ # g = genus[indx]
83
+ # f = family[indx]
84
+ # str = "Species: " + s + "\nGenus: " + g + "\nFamily: " + f
85
+ # return str
86
 
87
  with gr.Blocks(title="Bioscan-Clip") as demo:
88
  # open general files
 
108
  id_to_dna_emb_dict = pickle.load(f)
109
 
110
  # open taxonomy files
111
+ # with open("family.pickle", "rb") as f:
112
+ # family = [item.decode("utf-8") for item in pickle.load(f)]
113
+ # with open("genus.pickle", "rb") as f:
114
+ # genus= [item.decode("utf-8") for item in pickle.load(f)]
115
+ # with open("species.pickle", "rb") as f:
116
+ # species = [item.decode("utf-8") for item in pickle.load(f)]
117
 
118
  with gr.Column():
119
  process_id = gr.Textbox(label="ID:", info="Enter a sample ID to search for")
 
169
 
170
  id_btn.click(fn=getRandID, inputs=[], outputs=[rand_id, rand_id_indx])
171
  search_btn.click(fn=searchEmbeddings, inputs=[process_id, mod1, mod2],
172
+ outputs=[process_id_list, image0, image1, image2, image3, image4, image5, image6, image7, image8, image9, image10])
173
+ #tax0, tax1, tax2, tax3, tax4, tax5, tax6, tax7, tax8, tax9, tax10])
174
  examples = gr.Examples(
175
  examples=[["ABOTH966-22", "DNA", "DNA"],
176
  ["CRTOB8472-22", "DNA", "Image"],