天道酬勤,学无止境

问答

Using a dataset of filenames, create a dataset of images to tuples

I create a tensorflow dataset of filenames of many images in a folder. The images are named [index].jpg, where index is some integer used to identify the images. I have a dictionary of string 'index' to labels as tuples. How, using tf.data.Dataset.map, can I map the index to a label tuple? Here's the map_func I am trying to pass to the map function: def grabImages(filepath): index = getIndexFromFilePath(filepath) img = tf.io.read_file(filepath) img = translateImage(img) dictionary = getLabelDictionary() return index, img Where dictionary is the index to labels dict, index is the index of the

2021-09-24 19:51:12   python   tensorflow

Drag Drop Operation in QTreeWidget not copying the dropped item

I want to copy an item from a QTreeWidget-parent under another parent via a drag & drop mouse operation. For this, I have implemented the dropEvent() and am setting the dropAction to Qt.CopyAction. But anyway, the item I am dropping is not being copied under the new parent. E.g. -> dragging the user "schmidt" under the group "LON". Expected behaviour: the item I am dropping is being copied under the new parent. (e.g. user "schmidt" will be added under group "LON"). Full working code example: #!/usr/bin/env python3 # coding = utf-8 import sys from PyQt5 import QtCore, QtGui, QtWidgets class

2021-09-24 19:51:04   python   pyqt   drag-and-drop   pyqt5   qtreewidget

IBM MQ cmit and rollback with syncpoint

Infra-Overview: I have a setup where I am reading a set of messages from IBM MQ and processing those messages in k8 cluster env and sending it to the destination host. Issue: I observed that sometimes the flow of the messages is huge and before sending it to the destination host our pod gets failed and restarts, by this we are losing all the messages as we are following a read-and-delete approach from ibmmq example Expected Solution: I am looking for a solution where, until these messages are sent to the destination host, we don't lose the track of the messages. What I tried: We have a concept

2021-09-24 19:48:59   javascript   node.js   ibm-mq

NestJS Views Not gettings added to Dist

My folder structure is similar to below. public views src main.ts /users users.controller.ts /views my-view.hbs /books books.controller.ts /views my-view.hbs This is what i use to add the templates and views const app = await NestFactory.create<NestExpressApplication>( AppModule, ); console.log(join(__dirname, 'public')); app.useStaticAssets(join(__dirname, '..', 'public')); app.setBaseViewsDir(join(__dirname, '..', 'views')); app.setViewEngine('hbs'); hbs.registerPartials(join(__dirname, '..', 'views', 'partials')); My package.json scripts looks like this "scripts": { "prebuild": "rimraf dist

2021-09-24 19:48:37   node.js   typescript   nestjs

How can I remove the GMSPolyline in Swift 3

I'm making the GMSPolyline in the GoogleMap. When I want to remove the GMSPolyline by coding polyline.map = nil, but it can not working for me. I'm copy some coding in the below. (added the marker before, I need remove the polyline only) Thank you for your help!!! my coding: func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool { //MARK: create the GMSPolyline let polyline = GMSPolyline() //MARK: remove the old polyline from the GoogleMap polyline.map = nil let origin = "\(mapView.myLocation!.coordinate.latitude),\(mapView.myLocation!.coordinate.longitude)" let destination = "\

2021-09-24 19:46:59   google-maps   swift3   polyline

Static member error with instance member, xUnit

"An object reference is required for the non-static field" I have a static member which cannot be an instance member. This static member uses an instance of an object that is initialized in the constructor of the class through dependency injection, so it cannot be static. How could I solve this error? public class My { private readonly Fixture _fixture; public MyClass(Fixture fixture) { _fixture = fixture; } public static IEnumerable<object[]> TestCases() { yield return new object[] { Urls.BuildUrl(_fixture.WebAppUrl)}; } [Theory] [MemberData(nameof(TestCases))] ... public static class Urls {

2021-09-24 19:46:29   c#   static   xunit

Macro expansion contains free variable

My code compiles with the following error: Macro expansion contains free term variable Hello ... I have reduced it to minimal example: class Hello(val hi: String) { val xx = reify(hi) var yy = q"" } def setYYImpl(c: Context)(hExpr: c.Expr[Hello]): c.Expr[Hello] = { import c.universe._ val hello = c.eval(c.Expr[Hello](c.untypecheck(hExpr.tree.duplicate))) val xxVal = c.internal.createImporter(u).importTree(hello.xx.tree) c.Expr(q"""{val h = new Hello("HO"); h.yy=$xxVal; h}""") // it should set `h.yy` to Tree:"HO" } def setYY(hExpr: Hello): Hello = macro setYYImpl setYY(new Hello("HI")) After

2021-09-24 19:44:10   scala   scala-macros

How to delay a for loop in Jquery [duplicate]

This question already has answers here: How do I add a delay in a JavaScript loop? (34 answers) Closed 6 years ago. I am trying to make a image gallery and i am using a for loop to load all the images. but now I have the problem that it is going fast so I want to delay the the loop each time. I tried to set a timeout but that does not work does somebody know how to delay the loop with Jquery. js code: function test(){ var src = 'img/nature/'; var img = ['1.jpg']; var image = [ "1.jpg", "2.jpg", "3.jpg",'4.jpg','5.jpg','6.jpg','7.jpg' ]; for ( var i = 0; i < image.length; i = i + 1 ) { $('

2021-09-24 19:42:49   javascript   jquery

creating a html mailto with php

cannot use the mail function in php, will be creating a mailto link in html instead. (the kind you click on and it pops up a window) I have the body of the message saved under a variable $body and the email address saved under $email <?php echo" <a href="mailto: $to ?body= $body "> "; ?> I know that code would not work, how do I put the email address and the body variables in there? thanks

2021-09-24 19:42:44   php   html

Change Page size of Wor Document using Open Xml SDK 2.0

My application needs export custom report to Word document using Open xml Sdk 2.0 My Export function works fine except I need to increase Page size for showing it properly. (else word wrap will be an issue and Report won't look nice). Can any one suggest me how can I adjust Page size according to width of my report. I also need another help in alignment in word documet. Link for post is Horizontal Text alignment in Word using OpenXml Sdk 2.0

2021-09-24 19:42:10   .net   openxml