Spaces:
Sleeping
Sleeping
Publish the final 100 candidates with CIFs and synthesis reports
Browse filesFiles changed (5)
- README.md+6-6
- app.py+71-45
- catalogue.py+30-14
- data/crystal_previews.zip+2-2
- data/zenodo_24380323.zip → data/final_candidates_100.zipRenamed+2-2
12 unmodified lines1314151617181920212223242512 unmodified lines# MaterealizeBrowse the 100 bandgap-conditioned candidate structures from [Zenodo release v3, file (1)](https://doi.org/10.5281/zenodo.24380323).Each entry uses its published ID, from `release_v3_candidate_001` to `release_v3_candidate_100`. Different structures can share a formula.| Target bandgap (eV) | 1.0 | 1.34 | 1.5 | 2.0 | 2.5 || --- | ---: | ---: | ---: | ---: | ---: || Candidates | 29 | 14 | 7 | 20 | 30 |The original CIF, synthesis report and debate transcript (starting at round 1) are available for each entry. The image is a projection of the corresponding CIF; small cells may be repeated for visibility. Bandgaps are predictions, not measurements. Screening does not establish experimental synthesizability.The Space reads the deposited archive locally; it does not call an LLM or perform new calculations. The 14 historical invalid structures from Zenodo file (2) are not part of the candidate list.12 unmodified lines1314151617181920212223242512 unmodified lines# MaterealizeBrowse the [final 100 candidate structures and synthesis reports](https://huggingface.co/spaces/SNU-MICC/Materealize/resolve/main/data/final_candidates_100.zip?download=true): 67 bandgap-conditioned candidates and 33 unconditional candidates.Each entry uses its published ID, from `release_v3_candidate_001` to `release_v3_candidate_100`. Different structures can share a formula.| Target bandgap (eV) | 1.0 | 1.34 | 1.5 | 2.0 | 2.5 | 3.0 || --- | ---: | ---: | ---: | ---: | ---: | ---: || Conditioned candidates | 10 | 18 | 9 | 8 | 10 | 12 |The original CIF and synthesis report are available for each entry. The image is a projection of the corresponding CIF; small cells may be repeated for visibility. For unconditional candidates the release provides neither a target nor a predicted bandgap, so neither is displayed. Predicted bandgaps are not measurements. Screening does not establish experimental synthesizability.The Space reads the release locally; it does not call an LLM or run new property or synthesis predictions.
5 unmodified lines6789101112131415161718192021222 unmodified lines2526272829303132333435363738394041424344454647484950515253545556575859606162636413 unmodified lines787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191205 unmodified linesimport gradio as grfrom catalogue import FILENAMES, RECORD_URL, TARGET_COUNTS, load_catalogueROOT = Path(__file__).resolve().parentPUBLIC_CACHE = TemporaryDirectory(prefix='materealize-v3-')ENTRIES = load_catalogue(ROOT / 'data', Path(PUBLIC_CACHE.name))GROUPS = {target: tuple(c.id for c in ENTRIES.values() if c.target == target) for target in TARGET_COUNTS}DEFAULT_TARGET = '1.34'def choices(target):return [(f'{c.id} | {c.formula} | {c.predicted:.3f} eV', c.id) for c in (ENTRIES[k] for k in GROUPS[target])]def preview_cards(ids):2 unmodified linesdef detail(entry_id):c = ENTRIES[entry_id]cif, report, debate = (c.file(name) for name in FILENAMES)heading = (f'### {c.formula}\n\n`{c.id}` · Target: {c.target} eV'f' · Predicted: **{c.predicted:.3f} eV**')return (heading, report.read_bytes().decode('utf-8'), debate.read_bytes().decode('utf-8'),cif.read_bytes().decode('utf-8'), str(c.file('preview.png')), str(report), str(debate), str(cif))def select_target(target):ids = list(GROUPS[target][:5])return (ids, gr.update(value=preview_cards(ids), selected_index=None),gr.update(choices=choices(target), value=ids[0]), *detail(ids[0]))def refresh_previews(target):ids = sorted(random.sample(GROUPS[target], 5))return ids, gr.update(value=preview_cards(ids), selected_index=None)def select_material(target, entry_id):if entry_id not in GROUPS.get(target, ()):return (gr.skip(),) * 8return detail(entry_id)def select_card(target, ids, event: gr.SelectData):if not isinstance(event.index, int) or not 0 <= event.index < len(ids):return (gr.skip(),) * 9entry_id = ids[event.index]if entry_id not in GROUPS.get(target, ()):return (gr.skip(),) * 9return entry_id, *detail(entry_id)initial_ids = list(GROUPS[DEFAULT_TARGET][:5])initial = detail(initial_ids[0])TEXT = dict(interactive=False, autoscroll=False, show_copy_button=True, show_label=False, lines=15, max_lines=24)CSS = """13 unmodified lineswith gr.Blocks(title='Materealize', theme=gr.themes.Base(), css=CSS, analytics_enabled=False) as demo:gr.Image(str(ROOT / 'logo.png'), label='Materealize', show_label=False, container=False,height=75, interactive=False, show_download_button=False, show_fullscreen_button=False)gr.Markdown(f'**Materealize | Synthesis candidate explorer** · [Zenodo v3: 100 candidates]({RECORD_URL})\n\n''These are precomputed predictions for hypothetical structures, not experimentally validated syntheses.')gr.Markdown('### 1. Candidates by target bandgap')preview_ids = gr.State(initial_ids)with gr.Row():target = gr.Dropdown([(f'{k} eV ({n} candidates)', k) for k, n in TARGET_COUNTS.items()],value=DEFAULT_TARGET, label='Target bandgap', interactive=True, scale=3)refresh = gr.Button('Show another five structures', scale=1)gallery = gr.Gallery(value=preview_cards(initial_ids), label='Crystal structures', columns=5, elem_id='candidate-previews',rows=1, height='auto', object_fit='contain', allow_preview=False, interactive=False,show_share_button=False, show_fullscreen_button=False, show_download_button=False, format='png')gr.Markdown('### 2. Synthesis report and debate')material = gr.Dropdown(choices(DEFAULT_TARGET), value=initial_ids[0], label='Candidate',filterable=True, interactive=True)title = gr.Markdown(initial[0])with gr.Tabs():with gr.Tab('Synthesis report'):report = gr.Textbox(initial[1], label='Synthesis report', **TEXT)report_file = gr.DownloadButton('Download synthesis report (.txt)', value=initial[5], size='sm')with gr.Tab('Debate transcript'):debate = gr.Textbox(initial[2], label='Debate transcript (round 1 onwards)', **TEXT)debate_file = gr.DownloadButton('Download debate transcript (.txt)', value=initial[6], size='sm')with gr.Tab('Crystal structure'):with gr.Row():image = gr.Image(initial[4], label='Projection of the published CIF', height=260,interactive=False, show_download_button=False, scale=1, format='png')cif = gr.Textbox(initial[3], label='Original CIF', scale=2, **TEXT)cif_file = gr.DownloadButton('Download structure (.cif)', value=initial[7], size='sm')details = [title, report, debate, cif, image, report_file, debate_file, cif_file]target.input(select_target, target, [preview_ids, gallery, material, *details], api_name=False)refresh.click(refresh_previews, target, [preview_ids, gallery], api_name=False)material.input(select_material, [target, material], details, api_name='candidate')gallery.select(select_card, [target, preview_ids], [material, *details], api_name=False)gr.Markdown(f'[Published dataset]({RECORD_URL}) · [SNU MICC](https://micc.snu.ac.kr)')if __name__ == '__main__':5 unmodified lines6789101112131415161718192021222324252627282930313233342 unmodified lines3738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878813 unmodified lines1021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451465 unmodified linesimport gradio as grfrom catalogue import ARCHIVE, CONDITIONED, GENERATION_COUNTS, TARGET_COUNTS, UNCONDITIONAL, load_catalogueROOT = Path(__file__).resolve().parentPUBLIC_CACHE = TemporaryDirectory(prefix='materealize-final-')ENTRIES = load_catalogue(ROOT / 'data', Path(PUBLIC_CACHE.name))ALL = 'all'ARCHIVE_URL = f'https://huggingface.co/spaces/SNU-MICC/Materealize/resolve/main/data/{ARCHIVE}?download=true'def group_ids(mode, target):return [c.id for c in ENTRIES.values() if c.generation == modeand (mode == UNCONDITIONAL or target == ALL or str(c.target) == target)]def choices(ids):result = []for entry_id in ids:c = ENTRIES[entry_id]label = f'{c.id} | {c.formula}'if c.generation == CONDITIONED:label += f' | {c.predicted:.3f} eV'result.append((label, c.id))return resultdef preview_cards(ids):2 unmodified linesdef detail(entry_id):c = ENTRIES[entry_id]cif, report = c.file('structure.cif'), c.file('synthesis_report.txt')heading = f'### {c.formula}\n\n`{c.id}`'if c.generation == CONDITIONED:heading += (f' · Target: {c.target} eV'f' · Predicted: **{c.predicted:.3f} eV**')else:heading += ' · Unconditional'return (heading, report.read_bytes().decode('utf-8'), cif.read_bytes().decode('utf-8'),str(c.file('preview.png')), str(report), str(cif))def select_target(mode, target):ids = group_ids(mode, target)if not ids:return (gr.skip(),) * (3 + len(details))return (ids[:5], gr.update(value=preview_cards(ids[:5]), selected_index=None),gr.update(choices=choices(ids), value=ids[0]), *detail(ids[0]))def select_mode(mode):return (gr.update(visible=mode == CONDITIONED, value=ALL), *select_target(mode, ALL))def refresh_previews(mode, target):group = group_ids(mode, target)ids = sorted(random.sample(group, min(5, len(group))))return ids, gr.update(value=preview_cards(ids), selected_index=None)def select_material(mode, target, entry_id):if entry_id not in group_ids(mode, target):return (gr.skip(),) * len(details)return detail(entry_id)def select_card(mode, target, ids, event: gr.SelectData):if not isinstance(event.index, int) or not 0 <= event.index < len(ids):return (gr.skip(),) * (1 + len(details))entry_id = ids[event.index]if entry_id not in group_ids(mode, target):return (gr.skip(),) * (1 + len(details))return entry_id, *detail(entry_id)initial_group = group_ids(CONDITIONED, ALL)initial_ids = initial_group[:5]initial = detail(initial_ids[0])TEXT = dict(interactive=False, autoscroll=False, show_copy_button=True, show_label=False, lines=15, max_lines=24)CSS = """13 unmodified lineswith gr.Blocks(title='Materealize', theme=gr.themes.Base(), css=CSS, analytics_enabled=False) as demo:gr.Image(str(ROOT / 'logo.png'), label='Materealize', show_label=False, container=False,height=75, interactive=False, show_download_button=False, show_fullscreen_button=False)gr.Markdown('**Materealize | Synthesis candidate explorer** · 100 candidates\n\n''These are precomputed predictions for hypothetical structures, not experimentally validated syntheses.')gr.Markdown('### 1. Candidate structures')preview_ids = gr.State(initial_ids)mode = gr.Radio([(f'Bandgap-conditioned ({GENERATION_COUNTS[CONDITIONED]})', CONDITIONED),(f'Unconditional ({GENERATION_COUNTS[UNCONDITIONAL]})', UNCONDITIONAL)],value=CONDITIONED, label='Generation mode', interactive=True)with gr.Row():target = gr.Dropdown([('All target bandgaps', ALL)] + [(f'{k} eV ({n})', k) for k, n in TARGET_COUNTS.items()],value=ALL, label='Target bandgap', interactive=True, scale=3)refresh = gr.Button('Show another five structures', scale=1)gallery = gr.Gallery(value=preview_cards(initial_ids), label='Crystal structures', columns=5, elem_id='candidate-previews',rows=1, height='auto', object_fit='contain', allow_preview=False, interactive=False,show_share_button=False, show_fullscreen_button=False, show_download_button=False, format='png')gr.Markdown('### 2. Candidate details')material = gr.Dropdown(choices(initial_group), value=initial_ids[0], label='Candidate',filterable=True, interactive=True)title = gr.Markdown(initial[0])with gr.Tabs():with gr.Tab('Synthesis report'):report = gr.Textbox(initial[1], label='Synthesis report', **TEXT)report_file = gr.DownloadButton('Download synthesis report (.txt)', value=initial[4], size='sm')with gr.Tab('Crystal structure'):with gr.Row():image = gr.Image(initial[3], label='Projection of the candidate CIF', height=260,interactive=False, show_download_button=False, scale=1, format='png')cif = gr.Textbox(initial[2], label='Original CIF', scale=2, **TEXT)cif_file = gr.DownloadButton('Download structure (.cif)', value=initial[5], size='sm')details = [title, report, cif, image, report_file, cif_file]selection = [preview_ids, gallery, material, *details]mode.input(select_mode, mode, [target, *selection], api_name=False)target.input(select_target, [mode, target], selection, api_name=False)refresh.click(refresh_previews, [mode, target], [preview_ids, gallery], api_name=False)material.input(select_material, [mode, target, material], details, api_name='candidate')gallery.select(select_card, [mode, target, preview_ids], [material, *details], api_name=False)gr.Markdown(f'[Download all 100 candidates (.zip)]({ARCHIVE_URL}) · [SNU MICC](https://micc.snu.ac.kr)')if __name__ == '__main__':
2 unmodified lines345678910111213141516171819202122235 unmodified lines2930313233343536373839404142434445465 unmodified lines52535455565758592 unmodified linesfrom dataclasses import dataclassfrom hashlib import sha256import jsonfrom pathlib import Pathfrom zipfile import ZipFileRECORD_URL = 'https://zenodo.org/records/24380323'RECORD_SHA256 = 'b9d52e57c6e41dfd8645a8e0a2191f5247b3776d798490cf3f67a9c2a85cc8c4'TARGET_COUNTS = {'1.0': 29, '1.34': 14, '1.5': 7, '2.0': 20, '2.5': 30}FILENAMES = ('structure.cif', 'synthesis_report.txt', 'debate_transcript.txt')@dataclass(frozen=True)class Candidate:id: strformula: strtarget: strpredicted: floatfolder: Path@property5 unmodified linesdef load_catalogue(data_dir, public_cache):source = data_dir / 'zenodo_24380323.zip'if sha256(source.read_bytes()).hexdigest() != RECORD_SHA256:raise ValueError('The candidate archive does not match Zenodo record 24380323.')expected = {f'release_v3_candidate_{i:03d}' for i in range(1, 101)}entries = {}with ZipFile(source) as archive, ZipFile(data_dir / 'crystal_previews.zip') as previews:rows = json.loads(archive.read('Summary_of_final_candidates_100.json'))manifest = json.loads(previews.read('manifest.json'))if len(rows) != 100 or {r['folder'] for r in rows} != expected or set(manifest) != expected:raise ValueError('Candidate and preview indexes must cover all 100 published IDs.')for row in sorted(rows, key=lambda item: item['folder']):entry_id = row['folder']folder = public_cache / entry_idfolder.mkdir()for name in FILENAMES:5 unmodified linesif sha256(image).hexdigest() != manifest[entry_id]['png_sha256']:raise ValueError(f'Preview checksum mismatch: {entry_id}')(folder / 'preview.png').write_bytes(image)entries[entry_id] = Candidate(entry_id, row['reduced_formula'], str(row['target_bandgap (eV)']),row['predicted_bandgap (eV)'], folder)if Counter(c.target for c in entries.values()) != TARGET_COUNTS:raise ValueError('Published bandgap counts do not match the release.')return entries2 unmodified lines3456789101112131415161718192021222324252627285 unmodified lines34353637383940414243444546474849505152535455565758596061625 unmodified lines68697071727374752 unmodified linesfrom dataclasses import dataclassfrom hashlib import sha256import jsonfrom math import isfinitefrom pathlib import Pathfrom zipfile import ZipFileARCHIVE = 'final_candidates_100.zip'ARCHIVE_SHA256 = '775482483c45773ee2d57c17b922263e40f344990de2b95be13abda3b9cb5592'SUMMARY = 'Summary_of_final_candidates_100.json'CONDITIONED, UNCONDITIONAL = 'bandgap-conditioned', 'unconditional'GENERATION_COUNTS = {CONDITIONED: 67, UNCONDITIONAL: 33}TARGET_COUNTS = {'1.0': 10, '1.34': 18, '1.5': 9, '2.0': 8, '2.5': 10, '3.0': 12}FILENAMES = ('structure.cif', 'synthesis_report.txt')@dataclass(frozen=True)class Candidate:id: strformula: strgeneration: strtarget: float | Nonepredicted: float | Nonefolder: Path@property5 unmodified linesdef load_catalogue(data_dir, public_cache):source = data_dir / ARCHIVEif sha256(source.read_bytes()).hexdigest() != ARCHIVE_SHA256:raise ValueError('Candidate archive checksum mismatch.')expected = {f'release_v3_candidate_{i:03d}' for i in range(1, 101)}entries = {}with ZipFile(source) as archive, ZipFile(data_dir / 'crystal_previews.zip') as previews:rows = json.loads(archive.read(SUMMARY))manifest = json.loads(previews.read('manifest.json'))files = [f.filename for f in archive.infolist() if not f.is_dir()]allowed = {SUMMARY} | {f'{cid}/{name}' for cid in expected for name in FILENAMES}if set(files) != allowed or len(files) != len(allowed):raise ValueError('Unexpected, missing, or duplicated release file.')if len(rows) != 100 or {r['folder'] for r in rows} != expected or set(manifest) != expected:raise ValueError('Candidate and preview indexes must cover all 100 published IDs.')for row in sorted(rows, key=lambda item: item['folder']):entry_id = row['folder']generation = row['generation']target, predicted = row['target_bandgap (eV)'], row['predicted_bandgap (eV)']if generation == CONDITIONED:if not all(type(v) in (int, float) and isfinite(v) for v in (target, predicted)):raise ValueError(f'Missing or invalid conditioned bandgap: {entry_id}')elif generation != UNCONDITIONAL or target is not None or predicted is not None:raise ValueError(f'Unexpected generation mode or bandgap metadata: {entry_id}')folder = public_cache / entry_idfolder.mkdir()for name in FILENAMES:5 unmodified linesif sha256(image).hexdigest() != manifest[entry_id]['png_sha256']:raise ValueError(f'Preview checksum mismatch: {entry_id}')(folder / 'preview.png').write_bytes(image)entries[entry_id] = Candidate(entry_id, row['reduced_formula'], generation, target, predicted, folder)if (Counter(c.generation for c in entries.values()) != GENERATION_COUNTSor Counter(str(c.target) for c in entries.values() if c.generation == CONDITIONED) != TARGET_COUNTS):raise ValueError('Candidate counts do not match the release.')return entries
123version https://git-lfs.github.com/spec/v1oid sha256:8ed13502c84f70eb5483e7f423d86b0b2e402d72c24ebbfbc5f3d78775f8e90fsize 7544155123version https://git-lfs.github.com/spec/v1oid sha256:f66c0eb88da06f28ce994e5e4d3b8c8b776d43d6cd5dffedce9d5ca4e20cc829size 6992782
123version https://git-lfs.github.com/spec/v1oid sha256:b9d52e57c6e41dfd8645a8e0a2191f5247b3776d798490cf3f67a9c2a85cc8c4size 4914884123version https://git-lfs.github.com/spec/v1oid sha256:775482483c45773ee2d57c17b922263e40f344990de2b95be13abda3b9cb5592size 743125
README.md+6-6
app.py+71-45
catalogue.py+30-14
data/crystal_previews.zip+2-2
data/zenodo_24380323.zip → data/final_candidates_100.zipRenamed+2-2