swagger-coder / Cat-Generator

News title&abstract generator, using streamlit、GPT2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cat-News Title&Abstract Generator

环境

创建虚拟环境venv

  • python 3.7
  • streamlit 1.10.0
  • transformers 3.0.2
  • pytorch 1.11.0
pip install requirements.txt

pytorch无法下载

  • .\whl下whl文件放到venv\Lib\sit-packages
  • 转到venv\Lib\sit-packages目录,pip安装对应whl文件即可

项目结构

  • Cat-Text.py 主页面
  • pages\Cat-File.py 多页面
  • output_dir 模型文件
  • static 静态文件
  • utils 工具包
  • vocab\vocab.txt 词汇表

运行

streamlit run Cat-Text.py
## 指定端口
streamlit run Cat-Text.py --server.port 80`

内网穿透

  • 部署nginx,修改安装目录中的conf\nginx.conf
server {
    listen 80;
    server_name localhost;
    location / {
        proxy_pass http://0.0.0.0:8502/;    # streamlit server端口
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    
    location = /50x.html {
        root /usr/share/nginx/html;
    }
 }
  • 下载natapp ,根据教程 配置,注意端口与nginx一致(如8502)
  • C:\Users\username\.streamlit创建config.toml文件,并添加配置
[server]
port=8502 # change port number. By default streamlit uses 8501 port
headless=true # This will eliminate automatically open browser
[browser] # This ip and port will show in command prompt
serverAddress = "192.168.0.108" # Put your Local IP or Domain Name
serverPort = 8502

About

News title&abstract generator, using streamlit、GPT2


Languages

Language:Python 100.0%