【问题标题】:Run localhost server in Google Colab notebook在 Google Colab 笔记本中运行 localhost 服务器
【发布时间】:2020-06-19 14:47:23
【问题描述】:

我正在尝试在 Google Colab 中使用此代码在 Github 中以 repo 形式使用 Tensorflow 实现 Tacotron 语音合成,下面是我的代码,并且在使用本地主机服务器的步骤之前工作良好,我如何运行本地主机服务器在 Google Colab 的笔记本中?

我的代码:

!pip install tensorflow==1.3.0
import tensorflow as tf
print("You are using Tensorflow",tf.__version__)
!git clone https://github.com/keithito/tacotron.git
cd tacotron
pip install -r requirements.txt
!curl https://data.keithito.com/data/speech/tacotron-20180906.tar.gz | tar xzC /tmp
!python demo_server.py --checkpoint /tmp/tacotron-20180906/model.ckpt #requires localhost

不幸的是,从 Google Colab 在本地模式下运行对我没有帮助,因为要做到这一点,我需要在我的机器中下载太大的数据。
下面是我的最后一个输出,这里我应该打开localhost:8888来完成工作,所以我之前提到有没有办法在Google Colaboratory中运行localhost?

【问题讨论】:

    标签: python tensorflow jupyter-notebook google-colaboratory


    【解决方案1】:

    您可以使用 localtunnel 将端口暴露给公共互联网。
    安装localtinnel:

    !npm install -g localtunnel
    

    启动本地隧道:

    !lt --port 8888
    

    导航到它返回的 URL 以访问您的 Web UI。

    【讨论】:

      【解决方案2】:

      使用 ngrok 运行可公开访问的服务器的另一种方式:

      !pip install pyngrok --quiet
      from pyngrok import ngrok
      
      # Terminate open tunnels if exist
      ngrok.kill()
      
      # Setting the authtoken (optional)
      # Get your authtoken from https://dashboard.ngrok.com/auth
      NGROK_AUTH_TOKEN = ""
      ngrok.set_auth_token(NGROK_AUTH_TOKEN)
      
      # Open an HTTPs tunnel on port 5000 for http://localhost:5000
      public_url = ngrok.connect(port="5000", proto="http", options={"bind_tls": True})
      print("Tracking URL:", public_url)
      

      【讨论】:

        【解决方案3】:

        您可以使用 ngrok 或 remote.it 等工具来完成此操作

        它们为您提供了一个 URL,您可以从任何浏览器访问该 URL 以访问您在 8888 上运行的 Web 服务器

        示例 1:在

        上运行隧道 tensorboard
        !wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
        !unzip ngrok-stable-linux-amd64.zip
        
        get_ipython().system_raw('tensorboard --logdir /content/trainingdata/objectdetection/ckpt_output/trainingImatges/ --host 0.0.0.0 --port 6006 &')
        
        get_ipython().system_raw('./ngrok http 6006 &')
        
        ! curl -s http://localhost:4040/api/tunnels | python3 -c \
         "import sys, json; print(json.load(sys.stdin)['tunnels'][0]['public_url'])"
        

        在 colab 上运行此安装 ngrok,并创建一个类似 http://c11e1b53.ngrok.io/ 的链接

        Documentaion for NGROK

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2019-11-02
          • 2019-11-10
          • 2020-10-17
          • 2020-03-04
          • 2018-12-14
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多