You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
958 B
34 lines
958 B
12 months ago
|
# Import the idefics model from the swarms.models module
|
||
|
from swarms.models import Idefics
|
||
1 year ago
|
|
||
12 months ago
|
# Create an instance of the idefics model
|
||
|
model = Idefics()
|
||
1 year ago
|
|
||
12 months ago
|
# Define user input with an image URL and chat with the model
|
||
1 year ago
|
user_input = (
|
||
|
"User: What is in this image?"
|
||
|
" https://upload.wikimedia.org/wikipedia/commons/8/86/Id%C3%A9fix.JPG"
|
||
|
)
|
||
1 year ago
|
response = model.chat(user_input)
|
||
|
print(response)
|
||
|
|
||
12 months ago
|
# Define another user input with an image URL and chat with the model
|
||
1 year ago
|
user_input = (
|
||
|
"User: And who is that?"
|
||
|
" https://static.wikia.nocookie.net/asterix/images/2/25/R22b.gif/revision/latest?cb=20110815073052"
|
||
|
)
|
||
1 year ago
|
response = model.chat(user_input)
|
||
|
print(response)
|
||
|
|
||
12 months ago
|
# Set the checkpoint of the model to "new_checkpoint"
|
||
1 year ago
|
model.set_checkpoint("new_checkpoint")
|
||
12 months ago
|
|
||
|
# Set the device of the model to "cpu"
|
||
1 year ago
|
model.set_device("cpu")
|
||
12 months ago
|
|
||
|
# Set the maximum length of the chat to 200
|
||
1 year ago
|
model.set_max_length(200)
|
||
12 months ago
|
|
||
|
# Clear the chat history of the model
|
||
1 year ago
|
model.clear_chat_history()
|