Skip to content

Commit

Permalink
Merge pull request #61 from Photoroom/ben/cmd_fix
Browse files Browse the repository at this point in the history
[nit] Demo was stuck to 2000 samples..
  • Loading branch information
blefaudeux authored Jan 13, 2025
2 parents 892decc + 681c04d commit 3bc2636
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
27 changes: 17 additions & 10 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@ import (
)

func main() {
// Define flags

cropAndResize := flag.Bool("crop_and_resize", false, "Whether to crop and resize the images and masks")
concurrency := flag.Int("concurrency", 64, "The number of concurrent http requests to make")
itemFetchBuffer := flag.Int("item_fetch_buffer", 256, "The number of items to pre-load")
itemReadyBuffer := flag.Int("item_ready_buffer", 128, "The number of items ready to be served")
limit := flag.Int("limit", 2000, "The number of items to fetch")
profile := flag.Bool("profile", false, "Whether to profile the code")

// Parse the flags before setting the configuration values
flag.Parse()

// Initialize the configuration
config := datago.GetDatagoConfig()

sourceConfig := datago.SourceFileSystemConfig{RootPath: os.Getenv("DATAGO_TEST_FILESYSTEM")}
Expand All @@ -22,18 +33,14 @@ func main() {
config.ImageConfig = datago.ImageTransformConfig{
DefaultImageSize: 1024,
DownsamplingRatio: 32,
CropAndResize: *flag.Bool("crop_and_resize", false, "Whether to crop and resize the images and masks"),
CropAndResize: *cropAndResize,
}
config.SourceConfig = sourceConfig
config.Concurrency = *flag.Int("concurrency", 64, "The number of concurrent http requests to make")
config.PrefetchBufferSize = *flag.Int("item_fetch_buffer", 256, "The number of items to pre-load")
config.SamplesBufferSize = *flag.Int("item_ready_buffer", 128, "The number of items ready to be served")
config.Limit = *flag.Int("limit", 2000, "The number of items to fetch")

profile := flag.Bool("profile", false, "Whether to profile the code")
config.Concurrency = *concurrency
config.PrefetchBufferSize = *itemFetchBuffer
config.SamplesBufferSize = *itemReadyBuffer
config.Limit = *limit

// Parse the flags and instantiate the client
flag.Parse()
dataroom_client := datago.GetClient(config)

// Go-routine which will feed the sample data to the workers
Expand Down
4 changes: 2 additions & 2 deletions pkg/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func GetClient(config DatagoConfig) *DatagoClient {

switch config.SourceConfig.(type) {
case SourceDBConfig:
fmt.Println("Creating a DB-backed dataloader")
fmt.Println("Creating a DB-backed dataloader.", config.Limit, " max samples")

var err error
dbConfig := config.SourceConfig.(SourceDBConfig)
Expand All @@ -190,7 +190,7 @@ func GetClient(config DatagoConfig) *DatagoClient {
backend = BackendHTTP{config: &dbConfig, concurrency: config.Concurrency}
}
case SourceFileSystemConfig:
fmt.Println("Creating a FileSystem-backed dataloader")
fmt.Println("Creating a FileSystem-backed dataloader.", config.Limit, " max samples")
fsConfig := config.SourceConfig.(SourceFileSystemConfig)
generator = newDatagoGeneratorFileSystem(fsConfig)
backend = BackendFileSystem{config: &config, concurrency: config.Concurrency}
Expand Down

0 comments on commit 3bc2636

Please sign in to comment.