Skip to content

Commit

Permalink
Merge pull request PaddlePaddle#128 from LokeZhou/appflow_require
Browse files Browse the repository at this point in the history
Appflow require
  • Loading branch information
lyuwenyu authored Sep 8, 2023
2 parents 2177536 + 5a986f7 commit bfa38e1
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 21 deletions.
2 changes: 1 addition & 1 deletion applications/CVinW/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
`Grounded-SAM` 示例:

```python
from paddlemix import Appflow
from paddlemix.appflow import Appflow
from PIL import Image
task = Appflow(app="openset_det_sam",
models=["GroundingDino/groundingdino-swint-ogc","Sam/SamVitH-1024"]
Expand Down
16 changes: 9 additions & 7 deletions applications/Inpainting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
`Grounded-SAM-Inpainting` 示例:

```python
from paddlemix import Appflow
from paddlemix.appflow import Appflow
from PIL import Image
task = Appflow(app="inpainting",
models=["GroundingDino/groundingdino-swint-ogc","Sam/SamVitH-1024","stabilityai/stable-diffusion-2-inpainting"]
Expand All @@ -27,14 +27,19 @@ result = task(image=image_pil,prompt="bus",inpaint_prompt="a yellow van")
`Grounded-SAM-chatglm` 示例:

```python
from paddlemix import Appflow
from paddlemix.appflow import Appflow
from PIL import Image
task = Appflow(app="inpainting",
models=["THUDM/chatglm-6b","GroundingDino/groundingdino-swint-ogc","Sam/SamVitH-1024","stabilityai/stable-diffusion-2-inpainting"]
)
paddle.seed(1024)
image_pil = Image.open("bus.png").convert("RGB")
result = task(image=image_pil,inpaint_prompt="bus is changed to A school bus parked on the roadside")
inpaint_prompt = "bus is changed to A school bus parked on the roadside"
prompt = "Given caption,extract the main object to be replaced and marked it as 'main_object'," \
+ "Extract the remaining part as 'other prompt', " \
+ "Return main_object, other prompt in English" \
+ "Given caption: {}.".format(inpaint_prompt)
result = task(image=image_pil,prompt=prompt)
```

一些效果展示
Expand All @@ -50,7 +55,7 @@ result = task(image=image_pil,inpaint_prompt="bus is changed to A school bus par
### 文本引导的图像编辑(Text-Guided Image Inpainting)

```python
from paddlemix import Appflow
from paddlemix.appflow import Appflow
from PIL import Image
from ppdiffusers.utils import load_image
img_url = "https://paddlenlp.bj.bcebos.com/models/community/CompVis/stable-diffusion-v1-4/overture-creations.png"
Expand All @@ -75,6 +80,3 @@ image.save("a_yellow_cat.png")
| ![overture-creations](https://github.com/LokeZhou/PaddleMIX/assets/13300429/fe13b5f6-e773-41c2-9660-3b2747575fc1) | Face of a yellow cat, high resolution, sitting on a park bench|![overture-creations-mask](https://github.com/LokeZhou/PaddleMIX/assets/13300429/8c3dbb3a-5a32-4c22-b66e-7b82fcd18b77) |![a_yellow_cat](https://github.com/LokeZhou/PaddleMIX/assets/13300429/094ba90a-35c0-4a50-ac1f-6e0ce91ea931) |

</div>



9 changes: 6 additions & 3 deletions applications/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

Appflow提供丰富的开箱即用工具集,覆盖跨模态多场景应用,提供产业级的效果与极致的推理性能。
```python
from paddlemix import Appflow
from paddlemix.appflow import Appflow

paddle.seed(1024)
task = Appflow(app="text2image_generation",
Expand Down Expand Up @@ -71,7 +71,10 @@ pip install -r requirements.txt

```shell
git clone https://github.com/PaddlePaddle/PaddleMIX
python setup.py install
pip install -e .

#appflow 依赖包安装
pip install -r paddlemix/appflow/requirements.txt
```
## 快速开始

Expand All @@ -82,7 +85,7 @@ python setup.py install
PaddleMIX提供一键预测功能,无需训练,直接输入数据即可输出结果:

```python
>>> from paddlemix import Appflow
>>> from paddlemix.appflow import Appflow
>>> from ppdiffusers.utils import load_image

>>> task = Appflow(task="openset_det_sam",
Expand Down
9 changes: 6 additions & 3 deletions applications/README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

Appflow provides a rich set of out of the box tools that cover cross modal and multi scenario applications, providing industry level effects and ultimate reasoning performance.
```python
from paddlemix import Appflow
from paddlemix.appflow import Appflow

paddle.seed(1024)
task = Appflow(app="text2image_generation",
Expand Down Expand Up @@ -71,7 +71,10 @@ For more detailed tutorials on PaddlePaddle and PaddleNLP installation, please r

```shell
git clone https://github.com/PaddlePaddle/PaddleMIX
python setup.py install
pip install -e .

#appflow requirements
pip install -r paddlemix/appflow/requirements.txt
```
## Quick Start

Expand All @@ -82,7 +85,7 @@ Taking open world detection segmentation as an example:
PaddleMIX provides Appflow without training, and can directly input data to output results:

```python
>>> from paddlemix import Appflow
>>> from paddlemix.appflow import Appflow
>>> from ppdiffusers.utils import load_image

>>> task = Appflow(task="openset_det_sam",
Expand Down
4 changes: 2 additions & 2 deletions applications/image2image/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### 文本引导的图像放大(Text-Guided Image Upscaling)

```python
from paddlemix import Appflow
from paddlemix.appflow import Appflow
from PIL import Image
from ppdiffusers.utils import load_image

Expand Down Expand Up @@ -32,7 +32,7 @@ image.save("upscaled_white_cat.png")
### 文本图像双引导图像生成(Dual Text and Image Guided Generation)

```python
from paddlemix import Appflow
from paddlemix.appflow import Appflow
from PIL import Image
from ppdiffusers.utils import load_image

Expand Down
5 changes: 2 additions & 3 deletions applications/image2text/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
```
完成之后,可使用appflow 一键预测
```python
from paddlemix import Appflow
from paddlemix.appflow import Appflow
import requests

task = Appflow(app="image2text_generation",
Expand All @@ -49,7 +49,7 @@ result = task(image=image,minigpt4_text=minigpt4_text)
## blip2

```python
from paddlemix import Appflow
from paddlemix.appflow import Appflow
from ppdiffusers.utils import load_image

task = Appflow(app="image2text_generation",
Expand All @@ -64,4 +64,3 @@ result = task(image=image_pil,blip2_prompt=blip2_prompt)
|:----:|:----:|:----:|
|![mugs](https://github.com/LokeZhou/PaddleMIX/assets/13300429/b5a95002-bb30-4683-8e62-ed21879f24e1) | describe the image|of the two coffee mugs with cats on them|
</div>

1 change: 0 additions & 1 deletion paddlemix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# see the license for the specific language governing permissions and
# limitations under the license.

from .appflow import *
from .datasets import *
from .models import *
from .optimization import *
Expand Down
5 changes: 5 additions & 0 deletions paddlemix/appflow/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
numpy==1.23.5
nltk
paddlenlp>=2.6.0rc0
paddlespeech

1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
numpy
nltk
paddlenlp>=2.6.0rc0
tensorboardX
opencv-python
Expand Down

0 comments on commit bfa38e1

Please sign in to comment.