Able to run locally?

#3
by jefflee - opened

First thanks for this amazing project. I wonder whether I can clone the code and run app.py locally? It seems that not like the github repo, the files here are incomplete? Thanks.

CycleDiffusion is now a pipeline of HuggingFace Diffusers (doc here). To run this app locally, please refer to this colab. Running on a local machine is more or less the same as running on colab.

Thank you! This is very helpful.

jefflee changed discussion status to closed

Hi @ChenWu98 , sorry that I encountered another issue when I ran the code with streamlit. Do you have any thoughts what might cause the problem?
The app seems to start with generating many samples, occasionally throwing exceptions. It ignores the first few exceptions and proceeds, until crashes totally.
The webUI shows nothing but an exception. Thank you very much.

 streamlit run app.py

  You can now view your Streamlit app in your browser.

  Local URL: http://localhost:8501
  Network URL: http://172.20.1.2:8501

Fetching 16 files: 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 16/16 [00:00<00:00, 2939.89it/s]
Fetching 16 files: 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 16/16 [00:00<00:00, 1644.50it/s]
Fetching 16 files: 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 16/16 [00:00<00:00, 102.64it/s]
Fetching 16 files: 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 16/16 [00:00<00:00, 2388.64it/s]
Fetching 16 files: 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 16/16 [00:00<00:00, 917.43it/s]
Fetching 16 files: 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 16/16 [00:00<00:00, 239.59it/s]
Fetching 16 files: 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 16/16 [00:00<00:00, 123.96it/s]
Fetching 16 files: 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 16/16 [00:00<00:00, 380.91it/s]
/home/jefflee/.local/lib/python3.8/site-packages/torch/nn/modules/module.py:1383: UserWarning: positional arguments and argument "destination" are deprecated. nn.Module.state_dict will not accept them in the future. Refer to https://pytorch.org/docs/master/generated/torch.nn.Module.html#torch.nn.Module.state_dict for details.
  warnings.warn(
/home/jefflee/.local/lib/python3.8/site-packages/gradio/deprecation.py:40: UserWarning: `height` is deprecated in `Interface()`, please use it within `launch()` instead.
  warnings.warn(value)
Using cache from '/home/jefflee/cycledis/gradio_cached_examples/201' directory. If method or examples have changed since last caching, delete this folder to clear cache.
Caching examples at: '/home/jefflee/cycledis/gradio_cached_examples/202/log.csv'
2022-11-18 22:51:07.514 Uncaught app exception
Traceback (most recent call last):
  File "/home/jefflee/.local/lib/python3.8/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 563, in _run_script
    exec(code, module.__dict__)
  File "/home/jefflee/cycledis/app.py", line 410, in <module>
    gr.Markdown('''
  File "/home/jefflee/.local/lib/python3.8/site-packages/gradio/blocks.py", line 1063, in __exit__
    self.app = routes.App.create_app(self)
  File "/home/jefflee/.local/lib/python3.8/site-packages/gradio/routes.py", line 99, in create_app
    app = App(default_response_class=ORJSONResponse)
  File "/home/jefflee/.local/lib/python3.8/site-packages/gradio/routes.py", line 75, in __init__
    self.lock = asyncio.Lock()
  File "/usr/lib/python3.8/asyncio/locks.py", line 164, in __init__
    self._loop = events.get_event_loop()
  File "/usr/lib/python3.8/asyncio/events.py", line 639, in get_event_loop
    raise RuntimeError('There is no current event loop in thread %r.'
RuntimeError: There is no current event loop in thread 'ScriptRunner.scriptThread'.
Caching examples at: '/home/jefflee/cycledis/gradio_cached_examples/203/log.csv'
Using cache from '/home/jefflee/cycledis/gradio_cached_examples/200' directory. If method or examples have changed since last caching, delete this folder to clear cache.
2022-11-18 22:51:07.634 Uncaught app exception
Traceback (most recent call last):
  File "/home/jefflee/.local/lib/python3.8/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 563, in _run_script
    exec(code, module.__dict__)
  File "/home/jefflee/cycledis/app.py", line 410, in <module>
    gr.Markdown('''
  File "/home/jefflee/.local/lib/python3.8/site-packages/gradio/blocks.py", line 1063, in __exit__
    self.app = routes.App.create_app(self)
  File "/home/jefflee/.local/lib/python3.8/site-packages/gradio/routes.py", line 99, in create_app
    app = App(default_response_class=ORJSONResponse)
  File "/home/jefflee/.local/lib/python3.8/site-packages/gradio/routes.py", line 75, in __init__
    self.lock = asyncio.Lock()
  File "/usr/lib/python3.8/asyncio/locks.py", line 164, in __init__
    self._loop = events.get_event_loop()
  File "/usr/lib/python3.8/asyncio/events.py", line 639, in get_event_loop
    raise RuntimeError('There is no current event loop in thread %r.'
RuntimeError: There is no current event loop in thread 'ScriptRunner.scriptThread'.
  8%|โ–ˆโ–ˆโ–ˆโ–Ž                                        | 6/80 [00:01<00:19,  3.89it/s]/home/jefflee/.local/lib/python3.8/site-packages/gradio/deprecation.py:40: UserWarning: `height` is deprecated in `Interface()`, please use it within `launch()` instead.
  warnings.warn(value)
Caching examples at: '/home/jefflee/cycledis/gradio_cached_examples/254/log.csv'
Caching examples at: '/home/jefflee/cycledis/gradio_cached_examples/399/log.csv'
                                                                               Caching examples at: '/home/jefflee/cycledis/gradio_cached_examples/400/log.csv']
Using cache from '/home/jefflee/cycledis/gradio_cached_examples/401' directory. If method or examples have changed since last caching, delete this folder to clear cache.
2022-11-18 22:51:10.211 Uncaught app exception
Traceback (most recent call last):
  File "/home/jefflee/.local/lib/python3.8/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 563, in _run_script
    exec(code, module.__dict__)
  File "/home/jefflee/cycledis/app.py", line 410, in <module>
    gr.Markdown('''
  File "/home/jefflee/.local/lib/python3.8/site-packages/gradio/blocks.py", line 1063, in __exit__
    self.app = routes.App.create_app(self)
  File "/home/jefflee/.local/lib/python3.8/site-packages/gradio/routes.py", line 99, in create_app
    app = App(default_response_class=ORJSONResponse)
  File "/home/jefflee/.local/lib/python3.8/site-packages/gradio/routes.py", line 75, in __init__
    self.lock = asyncio.Lock()
  File "/usr/lib/python3.8/asyncio/locks.py", line 164, in __init__
    self._loop = events.get_event_loop()
  File "/usr/lib/python3.8/asyncio/events.py", line 639, in get_event_loop
    raise RuntimeError('There is no current event loop in thread %r.'
RuntimeError: There is no current event loop in thread 'ScriptRunner.scriptThread'.
100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 80/80 [00:46<00:00,  1.72it/s]
100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 80/80 [00:46<00:00,  1.71it/s]
100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 80/80 [00:48<00:00,  1.65it/s]
100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 80/80 [00:48<00:00,  1.64it/s]
100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 80/80 [00:48<00:00,  1.63it/s]
100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 90/90 [00:56<00:00,  1.60it/s]
100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 90/90 [00:56<00:00,  1.60it/s]
100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 90/90 [00:56<00:00,  1.60it/s]
100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 90/90 [00:56<00:00,  1.59it/s]
100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 90/90 [00:56<00:00,  1.59it/s]
 88%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‰     | 75/85 [00:45<00:06,  1.62it/s]
 87%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–     | 74/85 [00:44<00:06,  1.61it/s]
 76%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‰          | 65/85 [00:40<00:12,  1.62it/s]
 76%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‰          | 65/85 [00:40<00:12,  1.61it/s]
 74%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Š           | 63/85 [00:39<00:13,  1.58it/s]

In the browser, the error is:

 AttributeError: 'NoneType' object has no attribute 'blocks'

Traceback:
File "/home/jefflee/.local/lib/python3.8/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 563, in _run_script
    exec(code, module.__dict__)
File "/home/jefflee/cycledis/app.py", line 410, in <module>
    gr.Markdown('''
File "/home/jefflee/.local/lib/python3.8/site-packages/gradio/blocks.py", line 1057, in __exit__
    self.attach_load_events()
File "/home/jefflee/.local/lib/python3.8/site-packages/gradio/blocks.py", line 1565, in attach_load_events
    for component in Context.root_block.blocks.values():

Hi, it starts with generating many examples because I set cache_examples=True in app.py. Can you try turning this flag off? It works on my machine, but let me know if you encounter any errors.

Thank you @ChenWu98 ! Finally it runs.
A few things I changed (in case someone needs it):

  1. cache_examples=False (as you suggested)
  2. Create .streamlit/secrets.toml, which contains USER_TOKEN = "blahblah (one's huggingface token)"
  3. Shouldn't run with streamlit run app.py. Instead run it with python3 app.py.
  4. The newest streamlit==1.15.0 seems to have exceptions when loading. Downgrading it to 1.14.1 works.
  5. Change the last line from share=is_colab to share=True to enable a public address (as my GPU workstation is remote).

Sign up or log in to comment