sadgaj commited on
Commit
d5b06d5
1 Parent(s): a9a0760

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -15
app.py CHANGED
@@ -1,17 +1,28 @@
1
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
 
4
- def count_tokens(text):
5
- return 0
6
- # return len(TOKENIZER(text).input_ids)
7
 
 
 
 
 
 
 
8
 
9
- def run_detector(input_str):
10
- return 1
11
- # if count_tokens(input_str) < MINIMUM_TOKENS:
12
- # gr.Warning(f"Too short length. Need minimum {MINIMUM_TOKENS} tokens to run Binoculars.")
13
- # return ""
14
- # return f"{BINO.predict(input_str)}"
15
 
16
 
17
 
@@ -90,14 +101,18 @@ with gr.Blocks(css=css,
90
 
91
  examples = gr.Examples(
92
  examples=[
93
- ["List the initial 100 genes associated with a TAC-1:","a"],
94
- ["Enumerate the 100 most abundantly expressed starting genes in a cell:","a"],
95
- ["Could you determine the likely cell type based on these 100 most expressed genes? GM42418 IL1RAPL1 CDK8 MALAT1 JARID2 CAMK1D ZC3H7A GPHN LARS2 HEXB FGFR2 BRWD1 CASC5 MCCC2 NEAT1 PCNT NFIA NIPBL KIF23 GM26917 BZW1 MYOF PRPF38B HSPA9 HNRNPAB RORA ANLN AHNAK CIT ATRX ADGRG6 RTF1 SMC1A TENM1 HMCN1 LDLRAD4 QK AKAP13 LUC7L3 COL1A2 STX12 PTPN14 AKIRIN1 SNRNP48 MYH9 ATXN1 TRAPPC8 MKL1 MAN1A2 S100A14 DPM1 VPS13C FAM132A AMOT ITGA9 TCF4 ARF6 MBNL1 RPS6KC1 ANXA1 NAA35 SRSF6 GGTA1 2410089E03RIK CRYBG3 SMURF1 LITAF CERS6 BEND6 SRSF4 MTUS1 PLCH2 RBM27 ABCB7 PIEZO1 CUL2 RBMS1 RIC8B PTMA CEP128 HNRNPH1 HMMR KPNA4 MTDH EFNA5 EIF2B2 LARP4B SFSWAP CEP83 SLCO3A1 POLR2A KIF20A PGLYRP4 SLC39A11 ITPR2 CDC42SE1 COX7C NCAPG FKBP5 RIOK3 These genes are commonly found in:","a"],
96
- ["Distinguish between resistant and sensitive cancer cells in response to Cisplatin, using the data from the 100 most expressed genes in descending order MYL12B FTL MYL12A HIST1H4C RPL23 GSTP1 RPS3 ENO1 RPLP1 TXN ANXA2 PPP1CB B2M RPLP0 HSPA8 H2AFZ TPI1 ANXA1 RPL7 GAPDH CHP1 LDHA RPL3 S100A11 PRDX1 CALM2 CAPZA1 SLC25A5 RPS27 YWHAZ GNB2L1 PTBP3 RPS6 MOB1A S100A2 ACTG1 BROX SAT1 RPL35A CA2 PSMB4 RPL8 TBL1XR1 RPS18 HNRNPH1 RPL27 RPS14 RPS11 ANP32E RPL19 C6ORF62 RPL9 EEF1A1 RPL5 COLGALT1 NPM1 CCT6A RQCD1 CACUL1 RPL4 HSP90AA1 MALAT1 ALDOA PSMA4 SEC61G RPL38 PSMB5 FABP5 HSP90AB1 RPL35 CHCHD2 EIF3E COX4I1 RPL21 PAFAH1B2 PTMA TMED4 PSMB3 H3F3B AGO1 DYNLL1 ATP5A1 LDHB COX7B ACTB RPS27A PSME2 ELMSAN1 NDUFA1 HMGB2 PSMB6 TMSB10 SET RPL12 RPL37A RPS13 EIF1 ATP5G1 RPS3A TOB1.","a"],
97
- ["Evaluate a cancer cell's response to Erlotinib (resistant or sensitive), based on the cell's 100 most actively expressed genes in descending order MT-RNR2 MT-CO3 MT-CO1 RPL13 RPLP1 FTH1 GAPDH RPS8 PABPC1 FTL ANXA2 NCL RPS12 PTMA RPS14 CAV1 RPS3 RPS4X MT-CO2 RPL37 KRT7 RPS2 TMSB4X HSP90AA1 GSTP1 MT-ND4 MT-ATP6 S100A6 NAP1L1 RPL31 HSP90AB1 B2M RPL19 PPIA NUCKS1 MT-ND5 RPS27A TPM1 RPL18 ATP5G3 RPLP0 RPL8 TXN GNAS PSMA7 RPL30 MYL6 SLC25A5 RAD21 RTN4 RPL37A HSPD1 LRRFIP1 DEK MT-ND1 RPL11 TPT1 TMSB10 RPS24 SSRP1 LUC7L3 RPS20 KRT18 RPS16 RPL5 RPL35 RPS21 HNRNPC RPLP2 NACA GNB2L1 LGALS1 UQCRH FAU CHCHD2 RPL23 LDHB UBA52 HSP90B1 SEC62 RPL6 DSTN RPL27A RPL23A RPL22L1 KTN1 RPL14 CALM2 PRDX1 ADIPOR2 ZFAS1 HIST1H4C UQCRQ CALU PTTG1 EIF1 RPL26 RPL10A RAN ARPC2.","a"]
98
  ],
99
  examples_per_page=3,
100
  inputs=[input_box],
 
 
 
 
101
  )
102
 
103
 
@@ -124,7 +139,6 @@ with gr.Blocks(css=css,
124
  - As noted in our paper, Binoculars exhibit superior detection performance in the English language compared to other languages.
125
  """
126
  )
127
-
128
  with gr.Accordion("Cite our work", open=False):
129
  gr.Markdown(
130
  """
@@ -146,3 +160,4 @@ with gr.Blocks(css=css,
146
  clear_button.click(lambda: ("", ""), outputs=[input_box, output_text])
147
 
148
  app.launch()
 
 
1
  import gradio as gr
2
+ from transformers import (
3
+ AutoModelForCausalLM,
4
+ AutoTokenizer,
5
+ HfArgumentParser,
6
+ Trainer,
7
+ TrainingArguments,
8
+ AutoModelForSeq2SeqLM,
9
+ )
10
+ import torch
11
+ # model_folder = "zjunlp/chatcell-small"
12
+ # tokenizer = AutoTokenizer.from_pretrained(model_folder)
13
+ # model = AutoModelForSeq2SeqLM.from_pretrained(model_folder)
14
+ # model.eval()
15
 
16
 
 
 
 
17
 
18
+ def run_detector(input_text):
19
+ Encode the input text and generate a response with specified generation parameters
20
+ input_ids = tokenizer(input_text,return_tensors="pt").input_ids.to(device)
21
+ output_ids = model.generate(input_ids, max_length=512, num_return_sequences=1, no_repeat_ngram_size=2, top_k=50, top_p=0.95, do_sample=True)
22
+ # Decode and print the generated output text
23
+ output_text = tokenizer.decode(output_ids[0],skip_special_tokens=True)
24
 
25
+ return output_text
 
 
 
 
 
26
 
27
 
28
 
 
101
 
102
  examples = gr.Examples(
103
  examples=[
104
+ ["List the initial 100 genes associated with a TAC-1:"],
105
+ ["Enumerate the 100 most abundantly expressed starting genes in a cell:"],
106
+ ["Could you determine the likely cell type based on these 100 most expressed genes? GM42418 IL1RAPL1 CDK8 MALAT1 JARID2 CAMK1D ZC3H7A GPHN LARS2 HEXB FGFR2 BRWD1 CASC5 MCCC2 NEAT1 PCNT NFIA NIPBL KIF23 GM26917 BZW1 MYOF PRPF38B HSPA9 HNRNPAB RORA ANLN AHNAK CIT ATRX ADGRG6 RTF1 SMC1A TENM1 HMCN1 LDLRAD4 QK AKAP13 LUC7L3 COL1A2 STX12 PTPN14 AKIRIN1 SNRNP48 MYH9 ATXN1 TRAPPC8 MKL1 MAN1A2 S100A14 DPM1 VPS13C FAM132A AMOT ITGA9 TCF4 ARF6 MBNL1 RPS6KC1 ANXA1 NAA35 SRSF6 GGTA1 2410089E03RIK CRYBG3 SMURF1 LITAF CERS6 BEND6 SRSF4 MTUS1 PLCH2 RBM27 ABCB7 PIEZO1 CUL2 RBMS1 RIC8B PTMA CEP128 HNRNPH1 HMMR KPNA4 MTDH EFNA5 EIF2B2 LARP4B SFSWAP CEP83 SLCO3A1 POLR2A KIF20A PGLYRP4 SLC39A11 ITPR2 CDC42SE1 COX7C NCAPG FKBP5 RIOK3 These genes are commonly found in:"],
107
+ ["Distinguish between resistant and sensitive cancer cells in response to Cisplatin, using the data from the 100 most expressed genes in descending order MYL12B FTL MYL12A HIST1H4C RPL23 GSTP1 RPS3 ENO1 RPLP1 TXN ANXA2 PPP1CB B2M RPLP0 HSPA8 H2AFZ TPI1 ANXA1 RPL7 GAPDH CHP1 LDHA RPL3 S100A11 PRDX1 CALM2 CAPZA1 SLC25A5 RPS27 YWHAZ GNB2L1 PTBP3 RPS6 MOB1A S100A2 ACTG1 BROX SAT1 RPL35A CA2 PSMB4 RPL8 TBL1XR1 RPS18 HNRNPH1 RPL27 RPS14 RPS11 ANP32E RPL19 C6ORF62 RPL9 EEF1A1 RPL5 COLGALT1 NPM1 CCT6A RQCD1 CACUL1 RPL4 HSP90AA1 MALAT1 ALDOA PSMA4 SEC61G RPL38 PSMB5 FABP5 HSP90AB1 RPL35 CHCHD2 EIF3E COX4I1 RPL21 PAFAH1B2 PTMA TMED4 PSMB3 H3F3B AGO1 DYNLL1 ATP5A1 LDHB COX7B ACTB RPS27A PSME2 ELMSAN1 NDUFA1 HMGB2 PSMB6 TMSB10 SET RPL12 RPL37A RPS13 EIF1 ATP5G1 RPS3A TOB1."],
108
+ ["Evaluate a cancer cell's response to Erlotinib (resistant or sensitive), based on the cell's 100 most actively expressed genes in descending order MT-RNR2 MT-CO3 MT-CO1 RPL13 RPLP1 FTH1 GAPDH RPS8 PABPC1 FTL ANXA2 NCL RPS12 PTMA RPS14 CAV1 RPS3 RPS4X MT-CO2 RPL37 KRT7 RPS2 TMSB4X HSP90AA1 GSTP1 MT-ND4 MT-ATP6 S100A6 NAP1L1 RPL31 HSP90AB1 B2M RPL19 PPIA NUCKS1 MT-ND5 RPS27A TPM1 RPL18 ATP5G3 RPLP0 RPL8 TXN GNAS PSMA7 RPL30 MYL6 SLC25A5 RAD21 RTN4 RPL37A HSPD1 LRRFIP1 DEK MT-ND1 RPL11 TPT1 TMSB10 RPS24 SSRP1 LUC7L3 RPS20 KRT18 RPS16 RPL5 RPL35 RPS21 HNRNPC RPLP2 NACA GNB2L1 LGALS1 UQCRH FAU CHCHD2 RPL23 LDHB UBA52 HSP90B1 SEC62 RPL6 DSTN RPL27A RPL23A RPL22L1 KTN1 RPL14 CALM2 PRDX1 ADIPOR2 ZFAS1 HIST1H4C UQCRQ CALU PTTG1 EIF1 RPL26 RPL10A RAN ARPC2."]
109
  ],
110
  examples_per_page=3,
111
  inputs=[input_box],
112
+ # cache_examples=True,
113
+ # outputs=[output_text],
114
+ # fn=run_detector,
115
+
116
  )
117
 
118
 
 
139
  - As noted in our paper, Binoculars exhibit superior detection performance in the English language compared to other languages.
140
  """
141
  )
 
142
  with gr.Accordion("Cite our work", open=False):
143
  gr.Markdown(
144
  """
 
160
  clear_button.click(lambda: ("", ""), outputs=[input_box, output_text])
161
 
162
  app.launch()
163
+ # 📙