-
Notifications
You must be signed in to change notification settings - Fork 33
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
Integrate llama.cpp in Aprapipes and a module ImageToTextXForm which can describe an image #345
Open
kushaljain-apra
wants to merge
13
commits into
main
Choose a base branch
from
ks/llama_integration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f64bdad
add llama vcpkg port
kushaljain-apra 0f9f19d
update whisper portfile to support cuda
kushaljain-apra c864c13
add llm model abstract class
kushaljain-apra 5524ad9
add encoder model abstract class
kushaljain-apra 4365203
add Llava Model class
kushaljain-apra 7b00c68
add Clip Encoder Class
kushaljain-apra bee2754
add Model Strategy Class
kushaljain-apra efd4082
add SceneDescriptorXform Module
kushaljain-apra c60e9ec
add unit tests
kushaljain-apra d099726
update cmakelists.txt
kushaljain-apra 76d37ac
update framemetadata.h
kushaljain-apra 926a07f
Updated code to resolve PR conversations
kushaljain-apra 0a42a70
change SceneDescriptorXForm Module name to ImageToTextXForm Module
kushaljain-apra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#pragma once | ||
|
||
#include "EncoderModelAbstract.h" | ||
|
||
class ClipEncoderProps : public EncoderModelAbstractProps | ||
{ | ||
public: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move all the definition to cpp There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
ClipEncoderProps(std::string _modelPath); | ||
|
||
std::string modelPath; | ||
|
||
size_t getSerializeSize() | ||
{ | ||
return EncoderModelAbstractProps::getSerializeSize() + sizeof(modelPath); | ||
} | ||
|
||
private: | ||
friend class boost::serialization::access; | ||
|
||
template <class Archive> | ||
void serialize(Archive &ar, const unsigned int version) | ||
{ | ||
ar &boost::serialization::base_object<EncoderModelAbstractProps>(*this); | ||
ar & modelPath; | ||
} | ||
}; | ||
|
||
class ClipEncoder : public EncoderModelAbstract | ||
{ | ||
public: | ||
ClipEncoder(ClipEncoderProps _props); | ||
virtual ~ClipEncoder(); | ||
bool modelInit() override; | ||
bool modelTerm() override; | ||
bool modelInference(frame_container &inputFrameContainer, | ||
frame_container &outputFrameContainer, std::function<frame_sp(size_t)> makeFrame) override; | ||
bool validateUseCase(UseCase useCase) override; | ||
size_t getFrameSize() override; | ||
void storeFrames(frame_sp &frame); | ||
|
||
private: | ||
class Detail; | ||
boost::shared_ptr<Detail> mDetail; | ||
}; |
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,89 @@ | ||
#pragma once | ||
#include "stdafx.h" | ||
#include <boost/shared_ptr.hpp> | ||
#include <boost/serialization/base_object.hpp> | ||
#include <boost/archive/binary_iarchive.hpp> | ||
#include <boost/archive/binary_oarchive.hpp> | ||
#include <boost/iostreams/device/array.hpp> | ||
#include <boost/iostreams/stream.hpp> | ||
#include "Frame.h" | ||
#include <boost/function.hpp> | ||
#include "BoundBuffer.h" | ||
#include "FrameFactory.h" | ||
#include "CommonDefs.h" | ||
#include "FrameMetadata.h" | ||
#include "FrameMetadataFactory.h" | ||
#include "Command.h" | ||
#include "BufferMaker.h" | ||
#include "ModelEnums.h" | ||
#include "FrameContainerQueue.h" | ||
|
||
class EncoderModelAbstractProps | ||
{ | ||
public: | ||
EncoderModelAbstractProps(); | ||
|
||
EncoderModelAbstractProps(ModelArchitectureType _modelArchitecture, | ||
std::vector<FrameMetadata::FrameType> _inputTypes, | ||
std::vector<FrameMetadata::FrameType> _outputTypes, | ||
std::vector<UseCase> _useCases); | ||
|
||
size_t getSerializeSize() | ||
{ | ||
return sizeof(modelArchitecture) + sizeof(inputTypes) + | ||
sizeof(outputTypes) + sizeof(useCases) + sizeof(qlen); | ||
} | ||
|
||
ModelArchitectureType modelArchitecture; | ||
std::vector<FrameMetadata::FrameType> inputTypes; | ||
std::vector<FrameMetadata::FrameType> outputTypes; | ||
std::vector<UseCase> useCases; | ||
size_t qlen; | ||
|
||
private: | ||
friend class boost::serialization::access; | ||
|
||
template <class Archive> | ||
void serialize(Archive &ar, const unsigned int version) | ||
{ | ||
ar &boost::serialization::base_object<EncoderModelAbstractProps>(*this); | ||
ar & modelArchitecture; | ||
ar & inputTypes; | ||
ar & outputTypes; | ||
ar & useCases; | ||
ar & qlen; | ||
} | ||
}; | ||
|
||
class EncoderModelAbstract | ||
{ | ||
public: | ||
EncoderModelAbstract(std::string _modelName, EncoderModelAbstractProps props); | ||
~EncoderModelAbstract(); | ||
|
||
std::string getMyName() { return modelName; } | ||
|
||
boost::shared_ptr<FrameContainerQueue> getQue() { return mQue; } | ||
|
||
virtual bool modelInit() = 0; | ||
virtual bool modelTerm() = 0; | ||
virtual bool modelInference(frame_container &inputFrameContainer, | ||
frame_container &outputFrameContainer, std::function<frame_sp(size_t)> makeFrame) | ||
{ | ||
return false; | ||
} | ||
virtual size_t getFrameSize() = 0; | ||
|
||
virtual bool validateUseCase(UseCase useCase) = 0; | ||
|
||
bool init(); | ||
bool term(); | ||
bool step(frame_container &outputFrameContaine, std::function<frame_sp(size_t)> makeFrame); | ||
bool push(frame_container &inputFrameContainer, | ||
frame_container &outputFrameContainer, std::function<frame_sp(size_t)> _makeFrame); | ||
|
||
private: | ||
std::string modelName; | ||
boost::shared_ptr<FrameContainerQueue> mQue; | ||
boost::shared_ptr<EncoderModelAbstractProps> mProps; | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need a separate find lib if we are using find package for Llama?