Spaces:
Running
Running
Add FAQ
Browse files- FAQ-zh_CN.md +19 -0
- FAQ.md +19 -0
- README-zh_CN.md +2 -0
- README.md +2 -0
- app.py +23 -1
- demos/example.py +1 -1
- helper/Docs.py +10 -2
FAQ-zh_CN.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# FAQ
|
| 2 |
+
|
| 3 |
+
## 为什么我的应用在本地可以正常运行,在 Hugging Face Space 中界面无法正常显示?
|
| 4 |
+
|
| 5 |
+
在 Hugging Face Space 中,默认开启了 Gradio 的 ssr 模式,但是此功能目前还无法很好的兼容自定义组件,需要我们手动关闭。请在`demo.launch()`方法中添加`ssr_mode=False`参数:`demo.launch(ssr_mode=False)`。
|
| 6 |
+
|
| 7 |
+
## 为什么我的应用每次操作都需要等待一小段时间才会有响应
|
| 8 |
+
|
| 9 |
+
`modelscope_studio`将组件的加载反馈进行了单独抽离。由于 Gradio 的交互操作涉及到前后端通信,需要有一段加载中的等待时间,当没有`AutoLoading`组件时,页面将不会显示 Gradio 的加载状态。因此,建议您至少在全局使用一次`AutoLoading`组件,以显示兜底的加载反馈。
|
| 10 |
+
|
| 11 |
+
```python
|
| 12 |
+
import gradio as gr
|
| 13 |
+
import modelscope_studio.components.antd as antd
|
| 14 |
+
import modelscope_studio.components.base as ms
|
| 15 |
+
|
| 16 |
+
with gr.Blocks() as demo:
|
| 17 |
+
with ms.Application(), antd.ConfigProvider(), ms.AutoLoading():
|
| 18 |
+
antd.Button()
|
| 19 |
+
```
|
FAQ.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# FAQ
|
| 2 |
+
|
| 3 |
+
## Why does my application run normally locally but the interface doesn't display properly in Hugging Face Space?
|
| 4 |
+
|
| 5 |
+
In Hugging Face Space, Gradio's SSR mode is enabled by default, but this feature currently doesn't work well with custom components and needs to be manually disabled. Please add the `ssr_mode=False` parameter to the `demo.launch()`: `demo.launch(ssr_mode=False)`.
|
| 6 |
+
|
| 7 |
+
## Why does my application need to wait for a short time before responding to each operation?
|
| 8 |
+
|
| 9 |
+
`modelscope_studio` has separately extracted the loading feedback for components. Since Gradio's interactive operations involve frontend-backend communication, there needs to be a loading wait time. When there is no `AutoLoading` component, the page will not display Gradio's loading status. Therefore, it is recommended that you use the `AutoLoading` component at least once globally to display fallback loading feedback.
|
| 10 |
+
|
| 11 |
+
```python
|
| 12 |
+
import gradio as gr
|
| 13 |
+
import modelscope_studio.components.antd as antd
|
| 14 |
+
import modelscope_studio.components.base as ms
|
| 15 |
+
|
| 16 |
+
with gr.Blocks() as demo:
|
| 17 |
+
with ms.Application(), antd.ConfigProvider(), ms.AutoLoading():
|
| 18 |
+
antd.Button()
|
| 19 |
+
```
|
README-zh_CN.md
CHANGED
|
@@ -23,6 +23,8 @@
|
|
| 23 |
|
| 24 |
然而,当您的应用需要 Gradio 在 Python 端更多地处理内置数据时,`modelscope_studio`的组件可能不是最好的选择,但是不用担心,它可以很好地与已有的 Gradio 组件相结合,您仍然可以使用`modelscope_studio`来优化您的应用。
|
| 25 |
|
|
|
|
|
|
|
| 26 |
## 依赖
|
| 27 |
|
| 28 |
- Gradio >= 4.43.0
|
|
|
|
| 23 |
|
| 24 |
然而,当您的应用需要 Gradio 在 Python 端更多地处理内置数据时,`modelscope_studio`的组件可能不是最好的选择,但是不用担心,它可以很好地与已有的 Gradio 组件相结合,您仍然可以使用`modelscope_studio`来优化您的应用。
|
| 25 |
|
| 26 |
+
> 如果您正在 Hugging Face Space 中使用`modelscope_studio`,请在`demo.launch()`方法中添加`ssr_mode=False`参数:`demo.launch(ssr_mode=False)`,否则页面可能无法正常显示。
|
| 27 |
+
|
| 28 |
## 依赖
|
| 29 |
|
| 30 |
- Gradio >= 4.43.0
|
README.md
CHANGED
|
@@ -40,6 +40,8 @@ Compared to the original components of Gradio, `modelscope_studio` focuses more
|
|
| 40 |
|
| 41 |
However, when your application needs Gradio to handle more built-in data on the Python side, the components of `modelscope_studio` may not be the best choice, but don't worry, it integrates well with existing Gradio components, you can still use `modelscope_studio` to optimize your application.
|
| 42 |
|
|
|
|
|
|
|
| 43 |
## Dependencies
|
| 44 |
|
| 45 |
- Gradio >= 4.43.0
|
|
|
|
| 40 |
|
| 41 |
However, when your application needs Gradio to handle more built-in data on the Python side, the components of `modelscope_studio` may not be the best choice, but don't worry, it integrates well with existing Gradio components, you can still use `modelscope_studio` to optimize your application.
|
| 42 |
|
| 43 |
+
> If you are using `modelscope_studio` in Hugging Face Space, please add the `ssr_mode=False` parameter to the `demo.launch()`: `demo.launch(ssr_mode=False)`, otherwise the page may not display properly.
|
| 44 |
+
|
| 45 |
## Dependencies
|
| 46 |
|
| 47 |
- Gradio >= 4.43.0
|
app.py
CHANGED
|
@@ -62,7 +62,26 @@ def get_layout_templates():
|
|
| 62 |
|
| 63 |
layout_templates = get_layout_templates()
|
| 64 |
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
base_docs = get_docs("base")
|
| 68 |
antd_docs = get_docs("antd")
|
|
@@ -73,6 +92,9 @@ default_active_tab = "index"
|
|
| 73 |
index_menu_items = [{
|
| 74 |
"label": get_text("ModelScope-Studio", "ModelScope-Studio"),
|
| 75 |
"key": "overview"
|
|
|
|
|
|
|
|
|
|
| 76 |
}, {
|
| 77 |
"label":
|
| 78 |
get_text("Layout Templates", "布局模板"),
|
|
|
|
| 62 |
|
| 63 |
layout_templates = get_layout_templates()
|
| 64 |
|
| 65 |
+
misc_docs = Docs(__file__)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
class IndexDocsItem:
|
| 69 |
+
|
| 70 |
+
def __init__(self, module_name):
|
| 71 |
+
self.module_name = module_name
|
| 72 |
+
|
| 73 |
+
def get_css(self):
|
| 74 |
+
return misc_docs.get_css()
|
| 75 |
+
|
| 76 |
+
def render(self):
|
| 77 |
+
return misc_docs.render(module_name=self.module_name)
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
index_docs = {
|
| 81 |
+
"overview": IndexDocsItem("README"),
|
| 82 |
+
"faq": IndexDocsItem("FAQ"),
|
| 83 |
+
**layout_templates
|
| 84 |
+
}
|
| 85 |
|
| 86 |
base_docs = get_docs("base")
|
| 87 |
antd_docs = get_docs("antd")
|
|
|
|
| 92 |
index_menu_items = [{
|
| 93 |
"label": get_text("ModelScope-Studio", "ModelScope-Studio"),
|
| 94 |
"key": "overview"
|
| 95 |
+
}, {
|
| 96 |
+
"label": get_text("FAQ", "FAQ"),
|
| 97 |
+
"key": "faq"
|
| 98 |
}, {
|
| 99 |
"label":
|
| 100 |
get_text("Layout Templates", "布局模板"),
|
demos/example.py
CHANGED
|
@@ -7,4 +7,4 @@ with gr.Blocks() as demo:
|
|
| 7 |
antd.DatePicker()
|
| 8 |
|
| 9 |
if __name__ == "__main__":
|
| 10 |
-
demo.queue().launch()
|
|
|
|
| 7 |
antd.DatePicker()
|
| 8 |
|
| 9 |
if __name__ == "__main__":
|
| 10 |
+
demo.queue().launch(ssr_mode=False)
|
helper/Docs.py
CHANGED
|
@@ -30,6 +30,11 @@ class Docs:
|
|
| 30 |
filter(lambda x: not x.endswith("-zh_CN.md"),
|
| 31 |
self.markdown_files))
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
def _remove_formatter(self, markdown_text):
|
| 34 |
pattern = r"^ *---[\s\S]*?---"
|
| 35 |
replaced_text = re.sub(pattern, "", markdown_text)
|
|
@@ -163,7 +168,10 @@ class Docs:
|
|
| 163 |
css += module.css
|
| 164 |
return css
|
| 165 |
|
| 166 |
-
def render(self):
|
|
|
|
|
|
|
| 167 |
with gr.Blocks() as demo:
|
| 168 |
-
self._render_markdown(
|
|
|
|
| 169 |
return demo
|
|
|
|
| 30 |
filter(lambda x: not x.endswith("-zh_CN.md"),
|
| 31 |
self.markdown_files))
|
| 32 |
|
| 33 |
+
def _get_filename(self, filename: str):
|
| 34 |
+
if is_modelscope_studio:
|
| 35 |
+
return f"{filename}-zh_CN.md"
|
| 36 |
+
return f"{filename}.md"
|
| 37 |
+
|
| 38 |
def _remove_formatter(self, markdown_text):
|
| 39 |
pattern = r"^ *---[\s\S]*?---"
|
| 40 |
replaced_text = re.sub(pattern, "", markdown_text)
|
|
|
|
| 168 |
css += module.css
|
| 169 |
return css
|
| 170 |
|
| 171 |
+
def render(self, module_name: str = None):
|
| 172 |
+
parsed_filename = self._get_filename(
|
| 173 |
+
module_name) if module_name else None
|
| 174 |
with gr.Blocks() as demo:
|
| 175 |
+
self._render_markdown(
|
| 176 |
+
parsed_filename if parsed_filename else self.markdown_files[0])
|
| 177 |
return demo
|