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

docs: add finetuner docs #771

Merged
merged 26 commits into from
Jul 20, 2022
Merged

docs: add finetuner docs #771

merged 26 commits into from
Jul 20, 2022

Conversation

ZiniuYu
Copy link
Member

@ZiniuYu ZiniuYu commented Jul 18, 2022

This pr adds instructions on how to use fine-tuned model in clip-server trained by finetuner.
The doc is currently under user-guides. Will decide a more appropriate place later

@codecov
Copy link

codecov bot commented Jul 18, 2022

Codecov Report

Merging #771 (ee7c62e) into main (2b78b12) will decrease coverage by 0.24%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #771      +/-   ##
==========================================
- Coverage   82.09%   81.85%   -0.25%     
==========================================
  Files          17       17              
  Lines        1240     1251      +11     
==========================================
+ Hits         1018     1024       +6     
- Misses        222      227       +5     
Flag Coverage Δ
cas 81.85% <ø> (-0.25%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
client/clip_client/client.py 86.38% <0.00%> (-1.95%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ca03dca...ee7c62e. Read the comment docs.

Copy link
Member

@numb3r3 numb3r3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EMPTY?

@ZiniuYu
Copy link
Member Author

ZiniuYu commented Jul 18, 2022

docs failing. possible reason: ryanfox/sphinx-markdown-tables#36

Copy link
Member

@bwanglzu bwanglzu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Left some general comments.

@numb3r3
Copy link
Member

numb3r3 commented Jul 19, 2022

docs failing. possible reason: ryanfox/sphinx-markdown-tables#36

I will fix this issue in main since it breaks our doc building, please rebase your PR then.

docs/user-guides/finetuner.md Outdated Show resolved Hide resolved
docs/requirements.txt Outdated Show resolved Hide resolved
@bwanglzu
Copy link
Member

i guess we need to tweak the words a bit, I'll invite @violenil to take a look

@@ -0,0 +1,186 @@
# Fine-tune Models

Although CLIP-as-service has provided you a list of pre-trained models, you can also train your models.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can also fine-tune your models.

epochs=5,
learning_rate=1e-5,
loss='CLIPLoss',
cpu=False,
Copy link
Member

@numb3r3 numb3r3 Jul 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bwanglzu Just want to confirm will cpu=False work defaultly?

Copy link
Member

@bwanglzu bwanglzu Jul 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by default, finetuner use cpu, if you want to use gpu, you have to set cpu=False. @numb3r3

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me clarify my question. What I really want to ask is "Does finetuner currently allows training a model on GPU for free"?

```

The full dataset has been converted to `clip-fashion-train-data` and `clip-fashion-eval-data` and pushed to the cloud.
You can directly use them in Finetuner.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can directly use them in Finetuner.

You can directly use them by providing the dataset name in

train_da.push('fashion-sample')
```

The full dataset has been converted to `clip-fashion-train-data` and `clip-fashion-eval-data` and pushed to the cloud.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which can ...

run = finetuner.fit(
model='openai/clip-vit-base-patch32',
run_name='clip-fashion',
train_data='clip-fashion-train-data',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bwanglzu will finetuner accept docarray instance (rather than a name in hubble) as the dataset input?

Copy link
Member

@bwanglzu bwanglzu Jul 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, both are supported! it can be a string of docarray name, or a document array python instance @numb3r3

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prettry cool

You can push the resulting [`DocumentArray`](https://docarray.jina.ai/fundamentals/documentarray/) to the cloud using the [`.push`](https://docarray.jina.ai/api/docarray.array.document/?highlight=push#docarray.array.document.DocumentArray.push) method.

We use [fashion captioning dataset](https://github.com/xuewyang/Fashion_Captioning) as a sample dataset in this tutorial.
You can get the description and image url from the dataset:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You can get the description and image url from the dataset:
The following are examples of descriptions and image urls from the dataset:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can show the user how they can view these descriptions + urls themselves?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I can, but i think this will distract users and it is not the main topic of this tutorial


Since the tuned model generated from Finetuner contains richer information such as metadata and config, we now transform it to simpler structure used by CLIP-as-service.

* First create a new folder named `clip-fashion-cas` or anything you like. This will be the storage of the models to use in CLIP-as-service.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* First create a new folder named `clip-fashion-cas` or anything you like. This will be the storage of the models to use in CLIP-as-service.
* Firstly, create a new folder named `clip-fashion-cas` or name of your choice. This will be the storage of the models to use in CLIP-as-service.


* Second copy and move `clip-fashion/models/clip-text/model.onnx` to `clip-fashion-cas` and rename it to `textual.onnx`.

* Similarly, copy and move `clip-fashion/models/clip-vision/model.onnx` to `clip-fashion-cas` and rename it to `visual.onnx`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Similarly, copy and move `clip-fashion/models/clip-vision/model.onnx` to `clip-fashion-cas` and rename it to `visual.onnx`.
* Similarly, copy the vision model `clip-fashion/models/clip-vision/model.onnx` into `clip-fashion-cas` and rename the model to `visual.onnx`.

ZiniuYu and others added 4 commits July 19, 2022 17:55
@ZiniuYu ZiniuYu marked this pull request as ready for review July 19, 2022 11:18
Copy link
Member

@bwanglzu bwanglzu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -80,6 +80,8 @@
html_show_sourcelink = False
html_favicon = '_static/favicon.png'

intersphinx_mapping = {'docarray': ('https://docarray.jina.ai/', None), 'finetuner': ('https://finetuner.jina.ai/', None)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perfect, good catch


| Description | Image URL |
|---------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| subtly futuristic and edgy this liquid metal cuff bracelet is shaped from sculptural rectangular link | [https://n.nordstrommedia.com/id/sr3/<br/>58d1a13f-b6b6-4e68-b2ff-3a3af47c422e.jpeg](https://n.nordstrommedia.com/id/sr3/58d1a13f-b6b6-4e68-b2ff-3a3af47c422e.jpeg) |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we display the image, rather than simply print URL?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copyright?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also kept the original image urls since it is from the dataset

run = finetuner.fit(
model='openai/clip-vit-base-patch32',
run_name='clip-fashion',
train_data='clip-fashion-train-data',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prettry cool

epochs=5,
learning_rate=1e-5,
loss='CLIPLoss',
cpu=False,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me clarify my question. What I really want to ask is "Does finetuner currently allows training a model on GPU for free"?

docs/user-guides/server.md Outdated Show resolved Hide resolved
docs/user-guides/server.md Show resolved Hide resolved
docs/user-guides/server.md Outdated Show resolved Hide resolved
@github-actions
Copy link

📝 Docs are deployed on https://ft-finetuner-docs--jina-docs.netlify.app 🎉

@numb3r3 numb3r3 merged commit bc6b72e into main Jul 20, 2022
@numb3r3 numb3r3 deleted the finetuner-docs branch July 20, 2022 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants