mirror of
https://github.com/GayPizzaSpecifications/stable-diffusion-rpc.git
synced 2025-08-03 13:31:32 +00:00
Working C++ Sample
This commit is contained in:
@ -6,7 +6,7 @@ find_package(gRPC CONFIG REQUIRED)
|
|||||||
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||||
|
|
||||||
add_library(sdrpc src/StableDiffusion.proto)
|
add_library(sdrpc StableDiffusion.proto)
|
||||||
|
|
||||||
get_target_property(grpc_cpp_plugin_location gRPC::grpc_cpp_plugin LOCATION)
|
get_target_property(grpc_cpp_plugin_location gRPC::grpc_cpp_plugin LOCATION)
|
||||||
|
|
||||||
@ -17,6 +17,6 @@ protobuf_generate(TARGET sdrpc LANGUAGE grpc
|
|||||||
target_include_directories(sdrpc PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
|
target_include_directories(sdrpc PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
target_link_libraries(sdrpc PUBLIC protobuf::libprotobuf gRPC::grpc gRPC::grpc++)
|
target_link_libraries(sdrpc PUBLIC protobuf::libprotobuf gRPC::grpc gRPC::grpc++)
|
||||||
|
|
||||||
add_executable(sdrpc_sample src/sample.cpp)
|
add_executable(sdrpc_sample sample.cpp)
|
||||||
target_include_directories(sdrpc_sample PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
target_include_directories(sdrpc_sample PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
target_link_libraries(sdrpc_sample PRIVATE sdrpc)
|
target_link_libraries(sdrpc_sample PRIVATE sdrpc)
|
||||||
|
1
Clients/Cpp/StableDiffusion.proto
Symbolic link
1
Clients/Cpp/StableDiffusion.proto
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../Common/StableDiffusion.proto
|
23
Clients/Cpp/sample.cpp
Normal file
23
Clients/Cpp/sample.cpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#include "StableDiffusion.pb.h"
|
||||||
|
#include "StableDiffusion.grpc.pb.h"
|
||||||
|
|
||||||
|
#include <grpc++/grpc++.h>
|
||||||
|
|
||||||
|
using namespace gay::pizza::stable::diffusion;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
auto channel = grpc::CreateChannel("localhost:4546", grpc::InsecureChannelCredentials());
|
||||||
|
auto modelService = ModelService::NewStub(channel);
|
||||||
|
auto imageGenerationService = ImageGenerationService::NewStub(channel);
|
||||||
|
|
||||||
|
grpc::ClientContext context;
|
||||||
|
|
||||||
|
ListModelsRequest listModelsRequest;
|
||||||
|
ListModelsResponse response;
|
||||||
|
modelService->ListModels(&context, listModelsRequest, &response);
|
||||||
|
auto models = response.available_models();
|
||||||
|
for (const auto &item: models) {
|
||||||
|
std::cout << "Model Name: " << item.name() << std::endl;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
@ -1 +0,0 @@
|
|||||||
../../../Common/StableDiffusion.proto
|
|
@ -1,11 +0,0 @@
|
|||||||
#include <StableDiffusion.pb.h>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
using namespace gay::pizza::stable::diffusion;
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
ModelInfo info;
|
|
||||||
info.set_name("anything-4.5");
|
|
||||||
std::cout << info.DebugString() << std::endl;
|
|
||||||
return 0;
|
|
||||||
}
|
|
Reference in New Issue
Block a user