Commit 5db72e8d authored by Manuel Marschall's avatar Manuel Marschall
Browse files

new structure

parent 71a40ef8
Pipeline #6044 failed
image: "python:3.7"
stages:
- Static Analysis
- Test
# - upload
- makepdf
# - testdoc
# - deploydoc
mypy:
stage: Static Analysis
allow_failure: true
script:
- python --version
- pip install -r requirements.txt
- apt-get update -qq && apt-get install -y -qq pandoc
- python3 -m pip install --upgrade mypy
- python -m mypy datainformed-prior
flake8:
stage: Static Analysis
allow_failure: true
script:
- python --version
- pip install -r requirements.txt
- apt-get update -qq && apt-get install -y -qq pandoc
- python3 -m pip install --upgrade flake8
- flake8 --max-line-length=120 datainformed-prior/*.py
pylint:
stage: Static Analysis
allow_failure: true
script:
- python --version
- pip install -r requirements.txt
- apt-get update -qq && apt-get install -y -qq pandoc
- python3 -m pip install --upgrade pylint
- pylint -d C0301 datainformed-prior/*.py
unit_test:
stage: Test
allow_failure: true
script:
- python --version
- pip install -r requirements.txt
- apt-get update -qq && apt-get install -y -qq pandoc
- python3 -m pip install --upgrade pytest pytest-cov
- python3 -m pytest
- python3 -m pytest --cov-report term-missing --cov=datainformed-prior tests/
pypi:
stage: upload
allow_failure: true
script:
- cd python
- python --version
- pip install -r requirements.txt
- apt-get update -qq && apt-get install -y -qq pandoc
- python3 -m pip install --upgrade twine
- rm -rf dist
- echo "[distutils]" >> ~/.pypirc
- echo " index-servers =" >> ~/.pypirc
- echo " mcutility" >> ~/.pypirc
- echo "" >> ~/.pypirc
- echo "[mcutility]" >> ~/.pypirc
- echo " repository = https://test.pypi.org/legacy/" >> ~/.pypirc
- echo " username = __token__" >> ~/.pypirc
- echo " password = pypi-AgENdGVzdC5weXBpLm9yZwIkODc2YjkyNGMtYWFlMC00YTNkLTlmYzgtY2UzNzI5MGYwMzhlAAI6eyJwZXJtaXNzaW9ucyI6IHsicHJvamVjdHMiOiBbIm1jdXRpbGl0eSJdfSwgInZlcnNpb24iOiAxfQAABiCNlJgWB50pL7DURSrfmJ6Qh1i5JnUjA5mTA8V4UobzkA" >> ~/.pypirc
- echo "" >> ~/.pypirc
- python3 setup.py check sdist bdist # This will fail if your creds are bad.
# Since create generates a *.linux*.tar.gz file, we have to delete ist
# Otherwise twine complains that only one .tar.gz is allowed for upload
- rm -rf dist
- python3 setup.py sdist bdist_wheel
- twine upload -r mcutility dist/*.tar.gz
only:
- master
# test:
# stage: testdoc
# script:
# - python3 -m pip install -U sphinx nbsphinx nbsphinx-link m2r2 sphinx-rtd-theme pandoc
# - sphinx-build -b html docs/ public
# only:
# - branches
# except:
# - master
# pages:
# stage: deploydoc
# script:
# - python3 -m pip install -U sphinx nbsphinx nbsphinx-link m2r2 sphinx-rtd-theme pandoc
# - sphinx-build -b html docs/ public
# artifacts:
# paths:
# - public
# only:
# - master
compile_pdf:
image: miktex/miktex
stage: makepdf
script:
- apt-get update -y -qq && apt-get install -y -qq inkscape python3-pip python-pygments pandoc texlive-latex-recommended
- mpm --update-db --admin
- python3 -m pip install -U sphinx nbsphinx nbsphinx-link m2r2 sphinx-rtd-theme pandoc ipython mock numpy scipy matplotlib
- python3 -m pip install -r requirements.txt
- mkdir documentation
- cd docs
- make html
- make latex
- make latexpdf
- mv _build/latex/MCUtility.pdf ../../MCUtility.pdf
- cp -r _build/html/ ../../documentation/
artifacts:
paths:
- datainformed-prior.pdf
- documentation
only:
- master
# # License
# copyright Manuel Marschall (PTB) 2022
# This software is licensed under the BSD-like license:
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the distribution.
# DISCLAIMER
# ----------
# This software was developed at Physikalisch-Technische Bundesanstalt
# (PTB). The software is made available "as is" free of cost. PTB assumes
# no responsibility whatsoever for its use by other parties, and makes no
# guarantees, expressed or implied, about its quality, reliability, safety,
# suitability or any other characteristic. In no event will PTB be liable
# for any direct, indirect or consequential damage arising in connection
\ No newline at end of file
......@@ -17,39 +17,16 @@ available_methods = ["laplace", "thikonov", "gmrf", "mnist_regu", "generic", "ge
"latpush_linear", "eb_qmin"]
def get_generator(vae_quality):
if isinstance(vae_quality, str):
# PATH_DET = "deterministic/"
PATH_PROB = f"stochastic_{vae_quality}/"
PATH_ADD = "onnx_models/"
onnx_vae_good = ONNX_VAE_STO(PATH_ADD + PATH_PROB + f"{vae_quality}_probVAE_encoder.onnx",
PATH_ADD + PATH_PROB + f"{vae_quality}_probVAE_decoder.onnx")
tf_vae_good = onnx_vae_good.to_tensorflow()
prob_generator = ProbabilisticGenerator.from_vae(tf_vae_good, int(28*28), 20)
elif isinstance(vae_quality, (float, int)):
PATH_PROB_GOOD = "stochastic_good/"
# PATH_PROB_BAD = "stochastic_bad/"
PATH_PROB_BAD = "train_vae_test_no17/cont/"
PATH_ADD = "onnx_models/"
onnx_vae_good = ONNX_VAE_STO(PATH_ADD + PATH_PROB_GOOD + "good_probVAE_encoder.onnx",
PATH_ADD + PATH_PROB_GOOD + "good_probVAE_decoder.onnx")
tf_vae_good = onnx_vae_good.to_tensorflow()
prob_generator_good = ProbabilisticGenerator.from_vae(tf_vae_good, int(28*28), 20)
# onnx_vae_bad = ONNX_VAE_STO(PATH_ADD + PATH_PROB_BAD + "bad_probVAE_encoder.onnx",
# PATH_ADD + PATH_PROB_BAD + "bad_probVAE_decoder.onnx")
# tf_vae_bad = onnx_vae_bad.to_tensorflow()
tf_vae_bad = TF_VAE_OWN.from_path(PATH_PROB_BAD)
prob_generator_bad = ProbabilisticGenerator.from_vae(tf_vae_bad, int(28*28), 20)
prob_generator = ConvexProbabilisticGenerator(prob_generator_good, prob_generator_bad, vae_quality)
else:
raise ValueError(f"unknown quality: {vae_quality}")
return prob_generator
def get_generator():
vae_quality = "good"
PATH_PROB = f"stochastic_{vae_quality}/"
PATH_ADD = "onnx_models/"
onnx_vae_good = ONNX_VAE_STO(PATH_ADD + PATH_PROB + f"{vae_quality}_probVAE_encoder.onnx",
PATH_ADD + PATH_PROB + f"{vae_quality}_probVAE_decoder.onnx")
tf_vae_good = onnx_vae_good.to_tensorflow()
return ProbabilisticGenerator.from_vae(tf_vae_good, int(28*28), 20)
def draw_images(blur_operator_sigma=4,
......
numpy==1.21.2
scipy==1.7.1
matplotlib
packaging
corner==2.2.1
imageio==2.13.2
ipython==7.31.1
onnx==1.10.2
onnx-tf==1.9.0
pandas==1.1.5
scikit-image==0.19.0
seaborn==0.11.2
tensorflow==2.7.0
tensorflow-probability=0.15.0
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment