saharmor / dalle-playground

A playground to generate images from any text prompt using Stable Diffusion (past: using DALL-E Mini)
MIT License
2.77k stars 596 forks source link

no localtunnel response #94

Closed dcsan closed 2 years ago

dcsan commented 2 years ago

there seems to be an issue (on both my fork and your repo version) that now I don't get a response from localtunnel:

wonder if this is a temporary colab glitch, or something changed in their infra to prevent this backdooring...

image

MarcDerhammer commented 2 years ago

Same for me. My guess is Google cracking down.

edit: Looks like localtunnel is having service issues

MarcDerhammer commented 2 years ago

Nevermind, try it locally. Seems localtunnel might be having service issues. I was quick to jump to conclusions..

See https://github.com/localtunnel/localtunnel/issues/501

dcsan commented 2 years ago

oh it's that LT, which is always going down. Would ngrok work

ngrok was always more stable but not sure how to install that on a colab notebook https://ngrok.com/ https://ngrok.com/download

Does this notebook run on an M1 Mac btw? I assumed not.

eyaler commented 2 years ago

I just tested and both ngrok and argo are working for my in a non-related colab.

MarcDerhammer commented 2 years ago

I set up my instance to be exposed through cloudflared after reading https://github.com/localtunnel/localtunnel/issues/502 this.

Simply replace the !npm install -g localtunnel with this: !curl -L --output cloudflared.deb https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb && sudo dpkg -i cloudflared.deb && sudo cloudflared service install <insert your long token here>

the token can be retrieved after setting up an Access Tunnel within Cloudflare (Traffic -> Cloudflare Tunnel) and follow the instructions.

Choose Debian and 64-bit and copy the token from the Install and run a connector step

I already was using cloudflare for other things, so this was easy to setup using one of my existing domains.

After running the colab, Cloudflare should have detected the connection, and you can complete the configuration.

Make sure the "Service" matches the port. For example: http://localhost:8000 if running on port 8000

I did not try the "trycloudflare" setup, but if you're already using cloudflare this works fine.

trekkie1701c commented 2 years ago

Does this notebook run on an M1 Mac btw? I assumed not.

Colab does the actual processing so local architecture is irrelevant. You can (and I have!) actually run all of this only using a smartphone, so I don't see why a M1 Mac wouldn't work. The only blocking thing is how aggressively browser tabs are killed, as that could either kill the notebook (if you haven't enabled background execution on Colab Pro+) or the frontend.

dcsan commented 2 years ago

@trekkie1701c you can run a notebook locally too. any case no need for that just run the backend. however i get stuck here

Successfully built transformers dalle-mini
Failed to build tokenizers
ERROR: Could not build wheels for tokenizers, which is required to install pyproject.toml-based projects
dcsan commented 2 years ago

I got this connection running with ngrok

!pip install pyngrok

from threading import Thread
from pyngrok import ngrok
from time import sleep
import sys

app_port = 8000

def restart_ngrok():
  # close existing
  tunnels = ngrok.get_tunnels()
  for tunnel in tunnels:
    ngrok.disconnect(tunnel.public_url)
  public_url = ngrok.connect(app_port)
  print('ngrok public_url\n', public_url)
  ngrok_process = ngrok.get_ngrok_process()
  try:
      # Block until CTRL-C or some other terminating event
      ngrok_process.proc.wait()
  except KeyboardInterrupt:
      print(" Shutting down server.")
      ngrok.kill()

def app():
  print(f"Selected DALL-E Model - [{dalle_model}]")
  !python dalle-playground/backend/app.py --port {app_port} --model_version {dalle_model} --save_to_disk true --img_format jpeg --output_dir generations
  print(f'dalle starting on {app_port}')

if __name__=='__main__':
  print('start thread')
  t1 = Thread(target = app)
  a = t1.start()
  # make sure you don't restart the *blocking* ngrok service until after the app thread has started
  # !lt --port {app_port}
  restart_ngrok()  
sjhamilton commented 2 years ago

@dcsan Your solution seems to partially work. It generates a link for me, but when I try to use it on saharmor.me, the site is unable to find the DALL-E instance on the server. Any ideas or other info on what you did that might help me get it working?

dcsan commented 2 years ago

@sjhamilton I added a link to clarify when to start the ngrok:

tldr; # make sure you don't restart the *blocking* ngrok service until after the app thread has started

on the client side (nodeJS) I also have something like this:

export async function checkIfValidBackend(backendUrl: string) {
    const notebookUrl = AppConfig.getenv('notebookUrl') as string
    return await axios.get(backendUrl, {
        headers: {
            'Bypass-Tunnel-Reminder': "go",
            'mode': 'no-cors'
        },
        timeout: 5000 // only wait for 5s ?
    }).then(function (response) {
        return true
    }).catch(() => {
        sendBotAlert(`server check failed \`[${backendUrl}]\` `, 'error')
        sendBotAlert(`Please reboot ${notebookUrl} `, 'error')
        clog.error('server check failed:', backendUrl)
        return false
    })
}
GreekPhysique commented 2 years ago

I really don't get this. I put in your first set of code in my colab and i got a link @dcsan

But when i input the link into the front end website, it doesn't work.

This second jazz you wrote about the client side. I'm not sure what to do with that code

PanJohnny commented 2 years ago

@GreekPhysique same for me

dcsan commented 2 years ago

after you get the tunnel URL it can still take a few minutes til the model is ready. Not sure what else to say, it's working fine for me as a drop-in replacement.

if you've tried to run it a few times, one thing you might have to do is go to ngrok's site and register for free, to get an auth token. Then you can set it with:

ngrok.set_auth_token("your-long-token-string-here")

GreekPhysique commented 2 years ago

I'll try that.

PanJohnny commented 2 years ago

@dcsan isn't working for me, I looked into devtools and found this error: backend_api.js:35 Mixed Content: The page at 'https://saharmor.me/dalle-playground/?backendUrl=http://SOMETHING.ngrok.io/' was loaded over HTTPS, but requested an insecure resource 'http://SOMETHING.ngrok.io/'. This request has been blocked; the content must be served over HTTPS.

PanJohnny commented 2 years ago

Fixed it using HTTPS

dcsan commented 2 years ago

ok good one. yeah ngrok will give you both http and https URLs i'm connecting from the server side, so it's not as relevant...

GreekPhysique commented 2 years ago

Fixed it using HTTPS

@PanJohnny How did you fix it to HTTPS?

GreekPhysique commented 2 years ago

image

I just copy that Ngrok tunnel url and paste it into the Dall-e playground front end website and i get

image

GreekPhysique commented 2 years ago

So much to learn still guys. Sooo much to learn!

dcsan commented 2 years ago

rather than http://someurl just add an extra 's' httpS://someurl

GreekPhysique commented 2 years ago

Tried that. I can access the link through my browser and i get {"success":true} with https

but it just doesn't work on the DALL-E website.

PanJohnny commented 2 years ago

Worked after using my ngrok token

GreekPhysique commented 2 years ago

Ok i'll try that. where in the code do you set the token ? if you don't mind sharing @PanJohnny

PanJohnny commented 2 years ago

Here you go, worked for me

!pip install pyngrok

from threading import Thread
from pyngrok import ngrok
from time import sleep
import sys

app_port = 8000

ngrok.set_auth_token("YOUR_TOKEN")

def restart_ngrok():
  # close existing
  tunnels = ngrok.get_tunnels()
  for tunnel in tunnels:
    ngrok.disconnect(tunnel.public_url)
  public_url = ngrok.connect(app_port)
  print('ngrok public_url\n', public_url)
  ngrok_process = ngrok.get_ngrok_process()
  try:
      # Block until CTRL-C or some other terminating event
      ngrok_process.proc.wait()
  except KeyboardInterrupt:
      print(" Shutting down server.")
      ngrok.kill()

def app():
  print(f"Selected DALL-E Model - [{dalle_model}]")
  !python dalle-playground/backend/app.py --port {app_port} --model_version {dalle_model} --save_to_disk true --img_format jpeg --output_dir generations
  print(f'dalle starting on {app_port}')

if __name__=='__main__':
  print('start thread')
  t1 = Thread(target = app)
  a = t1.start()
  # make sure you don't restart the *blocking* ngrok service until after the app thread has started
  # !lt --port {app_port}
  restart_ngrok()  
PanJohnny commented 2 years ago

When it prints out the url paste it into the website and instead of http:// use https://. Also, you need to wait for this message: image That means that the model is loaded. Hope that helps 😃

GreekPhysique commented 2 years ago

Thanks very much! @PanJohnny. I'll give that a shot.

GreekPhysique commented 2 years ago

That didn't work. @PanJohnny . Did you pay for the ngrok service?

I'm think that might be the only difference here. I'm getting a warning like so when i go to the link:

image

Thanks so much for your help btw

PanJohnny commented 2 years ago

No, I use the free tear of the service

GreekPhysique commented 2 years ago

:(

GreekPhysique commented 2 years ago

I just suck

ennauata commented 2 years ago

same issue as @GreekPhysique :/

MarcDerhammer commented 2 years ago

Try to hit "visit site" or send the headers like the warning screen suggests. Guessing your requests are returning the warning screen until you do that.

PanJohnny commented 2 years ago

Hi made this gist with the ngrok stuff: https://gist.github.com/PanJohnny/edd7341c31255041a33daf229bf75125

EDIT: bad gist