Gradio 用户月活破百万之旅!

阅读更多
Gradio logo
  1. 其他
  2. NO_RELOAD

Gradio 新手?从这里开始: 快速开始

查看 发布历史

NO_RELOAD

if gr.NO_RELOAD:

描述

任何在 if gr.NO_RELOAD 代码块中的代码在源文件重新加载时不会被重新评估。这对于导入不喜欢被重新加载的模块 (如 tiktoken, numpy) 以及数据库连接和长时间运行的设置代码非常有用。

使用示例

import gradio as gr

if gr.NO_RELOAD:
	from transformers import pipeline
	pipe = pipeline("text-classification", model="cardiffnlp/twitter-roberta-base-sentiment-latest")

gr.Interface.from_pipeline(pipe).launch()