Skip to content

Commit

Permalink
feat: 0.1 (#10)
Browse files Browse the repository at this point in the history
* fix: upstream #116

* refactor: replace clip with open-clip

* feat: add custom models support and symmetry

* style: reformat with blacl

* style: reformat with blacl

* fix: broken compression on race condition #9

* fix: use uuid instead of seed as da name

* docs: update readme

* docs: update readme

* docs: update readme

* fix: update guided diffusion upstream

* fix: update guided diffusion upstream

* fix: update guided diffusion upstream

* fix: update guided diffusion upstream

* fix: update guided diffusion upstream

* fix: update guided diffusion upstream

* fix: update guided diffusion upstream

* fix: update guided diffusion upstream

* fix: update guided diffusion upstream

* fix: update guided diffusion upstream

* fix: update guided diffusion upstream

* feat: add spell checker

* feat: add spell checker

* feat: add spell checker

* feat: add spell checker

* feat: add spell checker

* feat: add spell checker

* feat: add spell checker

* feat: add spell checker

* feat: add spell checker

* feat: add spell checker

* feat: add spell checker

* feat: add spell checker

* feat: add spell checker

* feat: add spell checker

* feat: add spell checker

* feat: add spell checker

* feat: add spell checker

* feat: add spell checker
  • Loading branch information
hanxiao authored Jul 9, 2022
1 parent 9de4838 commit 7d1c626
Show file tree
Hide file tree
Showing 13 changed files with 1,567 additions and 129 deletions.
40 changes: 40 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Add 'label1' to any changes within 'example' folder or any subfolders
area/docs:
- docs/**/*
- ./*.md

area/testing:
- tests/**/*

area/setup:
- setup.py
- extra-requirements.txt
- requirements.txt
- MANIFEST.in

area/entrypoint:
- discoart/__init__.py

area/housekeeping:
- .github/**/*
- ./.gitignore
- ./*.yaml
- ./*.yml

area/cicd:
- .github/workflows/**/*

area/docker:
- Dockerfiles/**/*
- ./.dockerignore
- ./Dockerfile

area/script:
- scripts/**/*

component/nn:
- discoart/nn/**/*

component/resources:
- discoart/resources/**/*

7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ Disco Diffusion is a Google Colab Notebook that leverages CLIP-Guided Diffusion
pip install discoart
```

If you are not using DiscoArt under Google Colab, then other dependencies might be required.
If you are not using DiscoArt on Google Colab, then other dependencies might be required, [as described in the Dockerfile](./Dockerfile).

If you want to start a Jupyter Notebook on your own GPU machine, the easiest way is to [use our prebuilt Docker image](#run-in-docker).


## Get Started

Expand Down Expand Up @@ -190,7 +193,7 @@ We provide a prebuilt Docker image for running DiscoArt in the Jupyter Notebook.

```bash
# docker build . -t jinaai/discoart # if you want to build yourself
docker run -p 51000:8888 -v $(pwd):/home/jovyan/ --gpus all jinaai/discoart
docker run -p 51000:8888 -v $(pwd):/home/jovyan/ -v $HOME/.cache:/root/.cache --gpus all jinaai/discoart
```


Expand Down
45 changes: 27 additions & 18 deletions discoart/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

os.environ['KMP_DUPLICATE_LIB_OK'] = 'TRUE'

__version__ = '0.0.27'

__version__ = '0.1.0'


__all__ = ['create']

Expand Down Expand Up @@ -141,7 +143,7 @@ def create(init_document: 'Document') -> 'DocumentArray':
"""


def create(**kwargs) -> 'DocumentArray':
def create(**kwargs) -> Optional['DocumentArray']:
from .config import load_config, print_args_table, save_config_svg
from .runner import do_run

Expand Down Expand Up @@ -179,41 +181,47 @@ def create(**kwargs) -> 'DocumentArray':
gc.collect()
torch.cuda.empty_cache()

result = None

try:
result = do_run(_args, (model, diffusion, clip_models, secondary_model), device)
do_run(_args, (model, diffusion, clip_models, secondary_model), device)
except KeyboardInterrupt:
pass
except Exception as ex:
from .helper import logger

logger.error(f'{ex!r}')
finally:

_name = _args.name_docarray

if not os.path.exists(f'{_name}.protobuf.lz4'):
# not even a single document was created
return

from IPython import display

display.clear_output(wait=True)

_name = _args.name_docarray
from docarray import DocumentArray

if os.path.exists(f'{_name}.protobuf.lz4'):
from docarray import DocumentArray

_da = DocumentArray.load_binary(f'{_name}.protobuf.lz4')
if _da and _da[0].uri:
_da.plot_image_sprites(
skip_empty=True, show_index=True, keep_aspect_ratio=True
)
result = _da
_da = DocumentArray.load_binary(f'{_name}.protobuf.lz4')
if _da and _da[0].uri:
_da.plot_image_sprites(
skip_empty=True, show_index=True, keep_aspect_ratio=True
)
result = _da

print_args_table(vars(_args))
from IPython.display import FileLink, display

persist_file = FileLink(
f'{_name}.protobuf.lz4',
result_html_prefix=f'▶ (in case cloud storage failed) Download the result backup: ',
result_html_prefix=f'▶ Download the local backup (in case cloud storage failed): ',
)
config_file = FileLink(
f'{_name}.svg',
result_html_prefix=f'▶ Download the config as SVG image: ',
)
display(persist_file, config_file)
display(config_file, persist_file)

from rich import print
from rich.markdown import Markdown
Expand All @@ -238,7 +246,8 @@ def create(**kwargs) -> 'DocumentArray':
```
More usage such as plotting, post-analysis can be found in the [README](https://github.com/jina-ai/discoart).
'''
''',
code_theme='igor',
)
print(md)

Expand Down
8 changes: 6 additions & 2 deletions discoart/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ def load_config(
}
)

_id = random.getrandbits(128).to_bytes(16, 'big').hex()
if cfg['batch_name']:
da_name = f'{__package__}-{cfg["batch_name"]}-{cfg["seed"]}'
da_name = f'{__package__}-{cfg["batch_name"]}-{_id}'
else:
da_name = f'{__package__}-{cfg["seed"]}'
da_name = f'{__package__}-{_id}'
warnings.warn('you did not set `batch_name`, set it to have unique session ID')

cfg.update(**{'name_docarray': da_name})
Expand Down Expand Up @@ -99,6 +100,9 @@ def print_args_table(

param_str = Table(
title=cfg['name_docarray'],
caption=f'showing only non-default args'
if only_non_default
else 'showing all args ([b]bold *[/] args are non-default)',
box=box.ROUNDED,
highlight=True,
title_justify='left',
Expand Down
Loading

0 comments on commit 7d1c626

Please sign in to comment.