liuganghuggingface
commited on
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
@@ -1,6 +1,4 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
import spaces
|
4 |
import gradio as gr
|
5 |
import torch
|
6 |
import torch.nn as nn
|
@@ -8,6 +6,9 @@ import random
|
|
8 |
from rdkit import Chem
|
9 |
from rdkit.Chem import Draw
|
10 |
|
|
|
|
|
|
|
11 |
ATOM_SYMBOLS = ['C', 'N', 'O', 'H']
|
12 |
|
13 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
@@ -23,7 +24,7 @@ path = 'model_labeled'
|
|
23 |
def generate_random_smiles(length=10):
|
24 |
return ''.join(random.choices(ATOM_SYMBOLS, k=length))
|
25 |
|
26 |
-
@spaces.GPU
|
27 |
def generate_polymer(CH4, CO2, H2, N2, O2, guidance_scale):
|
28 |
properties = torch.tensor([CH4, CO2, H2, N2, O2], dtype=torch.float32).unsqueeze(0)
|
29 |
|
|
|
1 |
+
# import spaces
|
|
|
|
|
2 |
import gradio as gr
|
3 |
import torch
|
4 |
import torch.nn as nn
|
|
|
6 |
from rdkit import Chem
|
7 |
from rdkit.Chem import Draw
|
8 |
|
9 |
+
from graph_decoder.diffusion_model import GraphDiT
|
10 |
+
|
11 |
+
|
12 |
ATOM_SYMBOLS = ['C', 'N', 'O', 'H']
|
13 |
|
14 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
|
24 |
def generate_random_smiles(length=10):
|
25 |
return ''.join(random.choices(ATOM_SYMBOLS, k=length))
|
26 |
|
27 |
+
# @spaces.GPU
|
28 |
def generate_polymer(CH4, CO2, H2, N2, O2, guidance_scale):
|
29 |
properties = torch.tensor([CH4, CO2, H2, N2, O2], dtype=torch.float32).unsqueeze(0)
|
30 |
|