North-Sage commited on
Commit
30a6345
·
verified ·
1 Parent(s): f830e04
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -44,9 +44,8 @@ def save_high_quality_png(smiles, title, bw=True, padding=0.05):
44
 
45
  # Set a large canvas size for high resolution
46
  d = Draw.MolDraw2DCairo(1500, 1500)
47
-
48
  dopts = d.drawOptions()
49
- dopts.padding = padding
50
  dopts.maxFontSize = 2000
51
  dopts.bondLineWidth = 5
52
 
@@ -57,10 +56,8 @@ def save_high_quality_png(smiles, title, bw=True, padding=0.05):
57
  # Generate and display a similarity map based on atom importance scores
58
  SimilarityMaps.GetSimilarityMapFromWeights(molecule, atom_importance, draw2d=d)
59
 
60
- # Draw molecule with color highlights
61
  d.FinishDrawing()
62
-
63
- # Save to PNG file with high quality
64
  with open(f"{title}.png", "wb") as png_file:
65
  png_file.write(d.GetDrawingText())
66
 
@@ -82,7 +79,7 @@ def process_smiles(smiles, compute_explanation):
82
  # Generate molecule image
83
  if compute_explanation:
84
  img_path = "molecule"
85
- filepath= "molecule.png"
86
  save_high_quality_png(smiles, img_path)
87
  else:
88
  filepath = "molecule.png"
@@ -119,7 +116,13 @@ iface = gr.Interface(
119
  </p>
120
  </section>
121
  """,
122
-
 
 
 
 
 
 
123
  )
124
 
125
  iface.launch()
 
44
 
45
  # Set a large canvas size for high resolution
46
  d = Draw.MolDraw2DCairo(1500, 1500)
 
47
  dopts = d.drawOptions()
48
+ dopts.padding = padding
49
  dopts.maxFontSize = 2000
50
  dopts.bondLineWidth = 5
51
 
 
56
  # Generate and display a similarity map based on atom importance scores
57
  SimilarityMaps.GetSimilarityMapFromWeights(molecule, atom_importance, draw2d=d)
58
 
59
+ # Finish drawing and save the PNG
60
  d.FinishDrawing()
 
 
61
  with open(f"{title}.png", "wb") as png_file:
62
  png_file.write(d.GetDrawingText())
63
 
 
79
  # Generate molecule image
80
  if compute_explanation:
81
  img_path = "molecule"
82
+ filepath = "molecule.png"
83
  save_high_quality_png(smiles, img_path)
84
  else:
85
  filepath = "molecule.png"
 
116
  </p>
117
  </section>
118
  """,
119
+ # <<----------------- ADD YOUR CSS HERE ----------------->>
120
+ css="""
121
+ /* Brute-force invert the entire page inside the Space */
122
+ html, body {
123
+ filter: invert(100%);
124
+ }
125
+ """
126
  )
127
 
128
  iface.launch()