-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
bjoern
committed
Nov 7, 2023
1 parent
ed5a6f2
commit f4b7509
Showing
5 changed files
with
72 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from atman_magma.magma import Magma | ||
from atman_magma.attention_rollout import AttentionRolloutMagma | ||
import matplotlib.pyplot as plt | ||
|
||
from magma.image_input import ImageInput | ||
import PIL.Image as PilImage | ||
|
||
|
||
print('loading model...') | ||
model = Magma.from_checkpoint( | ||
checkpoint_path = "./mp_rank_00_model_states.pt", | ||
device = 'cuda:0' | ||
) | ||
ar = AttentionRolloutMagma(model = model) | ||
|
||
|
||
|
||
prompt =[ | ||
## supports urls and path/to/image | ||
#ImageInput('https://www.art-prints-on-demand.com/kunst/thomas_cole/woods_hi.jpg'), | ||
ImageInput('',pil=PilImage.open('openimages-panda.jpg')), | ||
'This is a picture of a' | ||
] | ||
|
||
relevance_maps = ar.run_on_image( | ||
prompt=prompt, | ||
target = 'Panda', # note rollout per se does not have a target | ||
) | ||
|
||
fig = plt.figure() | ||
plt.imshow(relevance_maps.reshape(12,12)) | ||
fig.savefig('panda-explained-rollout.jpg') | ||
print('panda-explained-rollout.jpg') |