Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unclear step (run codes) #177

Open
marshalleq opened this issue Jun 20, 2023 · 2 comments
Open

Unclear step (run codes) #177

marshalleq opened this issue Jun 20, 2023 · 2 comments

Comments

@marshalleq
Copy link

marshalleq commented Jun 20, 2023

Hi, in your instructions it says to install modelscope (done)

Then it says to 'run codes' and provides the code. I can't find where to run this code, it must be obvious, but I'm just not seeing it. Is it in the wrong order?

The code I'm talking about is this:

from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
from modelscope.outputs import OutputKeys

portrait_enhancement = pipeline(Tasks.image_portrait_enhancement, model='damo/cv_gpen_image-portrait-enhancement-hires')
result = portrait_enhancement('https://modelscope.oss-cn-beijing.aliyuncs.com/test/images/marilyn_monroe_4.jpg')
cv2.imwrite('result.png', result[OutputKeys.OUTPUT_IMG])

Was the first part supposed to bring up a gui somewhere?

Thanks.

@marshalleq marshalleq changed the title Unclear step (at least to me) Unclear step (run codes) Jun 20, 2023
@marshalleq
Copy link
Author

marshalleq commented Jun 20, 2023

Ah, I've seen another link now at the top of the page, it seems in the guide you're missing the part where it says the script is run in python. Might be obvious to a developer, but wasn't to me.

E.g. should read as below (you're missing the word python)

python
import cv2
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
from modelscope.outputs import OutputKeys

portrait_enhancement = pipeline(Tasks.image_portrait_enhancement, model='damo/cv_gpen_image-portrait-enhancement-hires')
result = portrait_enhancement('https://modelscope.oss-cn-beijing.aliyuncs.com/test/images/marilyn_monroe_4.jpg')
cv2.imwrite('result.png', result[OutputKeys.OUTPUT_IMG])

Haven't tested this yet, but will do.

@marshalleq
Copy link
Author

marshalleq commented Jun 21, 2023

I have now tested. For others coming here, what you need to do is drop to a console and literally type python3 from bash on it's own then press .

After that, copy and paste the code into the python console that comes up.

The files will be downloaded into your users home directoy under .cache/modelscope.
Your python window will seem to be hung, however CTRL-C, CTRL-D gets you out of it. The last line I had is as below, which I assume is the correct last line:

>>> cv2.imwrite('result.png', result[OutputKeys.OUTPUT_IMG])

If possible, this should be updated in the instructions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant