msiron commited on
Commit
fbd13ac
·
1 Parent(s): 5b4c478
Files changed (1) hide show
  1. app.py +27 -18
app.py CHANGED
@@ -3,7 +3,7 @@ import os
3
  import gradio as gr
4
  import numpy as np
5
  import plotly.graph_objs as go
6
- from datasets import load_dataset
7
  from pymatgen.analysis.phase_diagram import PDPlotter, PhaseDiagram
8
  from pymatgen.core import Composition, Structure
9
  from pymatgen.core.composition import Composition
@@ -14,25 +14,32 @@ from pymatgen.entries.computed_entries import (
14
 
15
  HF_TOKEN = os.environ.get("HF_TOKEN")
16
 
 
 
17
  # Load only the train split of the dataset
18
- dataset = load_dataset(
19
- "LeMaterial/leDataset",
20
- token=HF_TOKEN,
21
- split="train",
22
- columns=[
23
- "lattice_vectors",
24
- "species_at_sites",
25
- "cartesian_site_positions",
26
- "energy",
27
- "energy_corrected",
28
- "immutable_id",
29
- "elements",
30
- "functional",
31
- ],
32
- )
 
 
 
 
33
 
34
  # Convert the train split to a pandas DataFrame
35
- train_df = dataset.to_pandas()
 
36
  del dataset
37
 
38
 
@@ -141,7 +148,9 @@ warning_message += " now please take caution when analyzing the results of this"
141
  warning_message += " application."
142
 
143
 
144
- message = '<div class="alert"><span class="closebtn" onclick="this.parentElement.style.display="none";">&times;</span>{}</div>Generate a phase diagram for a set of elements using LeMat-Bulk data.'.format(warning_message)
 
 
145
 
146
  # Create Gradio interface
147
  iface = gr.Interface(
 
3
  import gradio as gr
4
  import numpy as np
5
  import plotly.graph_objs as go
6
+ from datasets import concatenate_datasets, load_dataset
7
  from pymatgen.analysis.phase_diagram import PDPlotter, PhaseDiagram
8
  from pymatgen.core import Composition, Structure
9
  from pymatgen.core.composition import Composition
 
14
 
15
  HF_TOKEN = os.environ.get("HF_TOKEN")
16
 
17
+ subsets = ["compatible_pbe", "compatible_pbesol", "compatible_scan", "non_compatible"]
18
+
19
  # Load only the train split of the dataset
20
+
21
+ datasets = []
22
+ for subset in subsets:
23
+ dataset = load_dataset(
24
+ "LeMaterial/leMat-Bulk",
25
+ subset,
26
+ token=HF_TOKEN,
27
+ columns=[
28
+ "lattice_vectors",
29
+ "species_at_sites",
30
+ "cartesian_site_positions",
31
+ "energy",
32
+ "energy_corrected",
33
+ "immutable_id",
34
+ "elements",
35
+ "functional",
36
+ ],
37
+ )
38
+ datasets.append(dataset["train"])
39
 
40
  # Convert the train split to a pandas DataFrame
41
+ dataset = concatenate_datasets(datasets)
42
+ train_df = dataset["train"].to_pandas()
43
  del dataset
44
 
45
 
 
148
  warning_message += " application."
149
 
150
 
151
+ message = '<div class="alert"><span class="closebtn" onclick="this.parentElement.style.display="none";">&times;</span>{}</div>Generate a phase diagram for a set of elements using LeMat-Bulk data.'.format(
152
+ warning_message
153
+ )
154
 
155
  # Create Gradio interface
156
  iface = gr.Interface(